Category "spring-data-jpa"

Spring Data: can I create a method in the @Repository with a name what return list of object if String equals to constant?

Guess easier if I show you my example: @Entity class User { Long id; Status status; } enum Status { NEW("N"), DELETED("D") } I have an AttributeCon

Hibernate / Spring Data - get executed sql queries count

I'm working on presentation in which I would like to show difference in number of executed sql queries between deleteByPost() method with and without custom que

pgp_sym_decrypt not working with JPA nativeQuery. Always throw error

Hi I'm working on a Spring Boot Project using PSQL. I have a model that is implemented pgcrypto like this, @ColumnTransformer( read = "pgp_sym_decrypt( ms

AssertionFailure: null identifier when try to save identifying one-to-one relation

I'm trying to make identifying relation with Spring Data JPA. And following is my (simplified) entities. @Entity class AuthorizationCodeEntity( @MapsId

Spring Boot - Hibernate - Table does not exists

I have a 3rd party jar that holds all the entities and mapping. I am currently using this jar successfully in a classic Spring-MVC application, but now I am t

Named parameter not bound : DATE_FORMAT Native Query in Spring Boot

I am trying to get table data as list using select query between dateFrom and current date using MySQL Native Query in Spring Boot. and MySQL database field dat

How to write a unit test for spring specification?

I created a builder class which construct Specifications object. It is used for creating queries for JpaSpecificationExecutor. The builder is used, because I ha

unable to test UUID

I have a spring boot 2.6.7 app, using Liquibase, Gradle and Spock. I have a class that uses a guid format string as the ID: @Entity @Table(name = "devices") pu

How to call repository method in entity listener

I'm trying to make call to repository inside my Entity Listener, when I call repository.findById() method inside my @prePersist method the same method is callin

How can I test the Remember Me checkbox

I am currently setting up a service allowing user login on a web portal, for comfort I have added the "Remember Me" function using Spring Security by using a pe

Document QueryDSL endpoint with Swagger

I'm using Spring Boot Data, QueryDSL and Swagger. I've define endpoint like this: @GetMapping public ResponseEntity<?> listOfThings( @PageableDef

Northwind - creating orders (MySQL + Spring boot)

I have DB with schema like below: I would like to create an Order. I created DAO of Order with all columns like below and added there relations like this: O

detached entity passed to persist - on findByMethod

I understand the error message and i know how to solve it, but i want to know why it occurs in this specific place especially on a find method. I created a mini

Integration Eclipse Collections with Spring Data JPA

is it possible integration eclipse collections with spring data jpa + hibernate? for example: import org.springframework.data.jpa.repository.JpaRepository; im

Spring jpa native query sorting adding prefix to order by field name

I have problem with sorting. Repository method: @Query(nativeQuery = true, value = "SELECT D.ID as dealerId , D.NAME as dealerName, K.ID as kpiId, " + "

How can I get a sequence number from an oracle database with jpaRepository?

I´m trying to get a sequence number from an oracle database using a jpaRepository. The main problem is because I don´t have any Object in JpaReposi

Getting Exception while inserting data in Redshift DB

while fetching data from database It is working fine when trying to insert data in Redshift database getting exception MY POJO class : Quote.java @Entity publi

Using Liquibase to initialize in-memory H2 for unit tests in Spring Boot application

I've used in-mem databases in Spring JPA tests many times, and never had a problem. This time, I have a bit more complex schema to initialize, and that schema m

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: FQPropretyName, could not initialize proxy - no Session

I am trying a ManyToOne Bi-Directional Association using SpringBoot, SpringDataJpa along with a unit test using SpringBootTest. However the test fails with the

What difference does it make to put an annotation @Lob or not?

There is a request table in my database. Here is its structure Usually I created the entity with my hands, but this time I decided to generate it from the data