Category "spring-data-jpa"

How to get Count of OneToMany field in JPA Enity?

How can we get the count of OneToMany field of JPA entity as querying count for each parent entity while fetching as a list is costly and there is no way in JPA

JPA cascading delete fails with custom delete method

I ran into an error with custom delete method in spring data jpa. Basically there's a bag which contains items, and when deleting the bag, all the items in it s

How to get Grails Gorm autocomplete in regular Spring Data JPA

Grails GORM is able to autogenerate ORM findBy[fieldName] and related methods for each of the fields in the entity, I'm not sure what magic it uses to do this I

Hibernate: How to create multi-column index on join table

I have two entity classes: Taco @Data @Entity @Table(name="Taco") public class Taco { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) @

Struggling to switch between databases at runtime with Spring boot

I'm trying to change which database is used at runtime (like from H2 to MySQL and back). Is it also possible to make both of them be used simultaneously (meanin

Use Stream return type in Spring Boot controller lead to "java.sql.SQLException: Closed Resultset: next"

When streaming result from JpaRepository to Rest API, I have an exception "java.sql.SQLException: Closed Resultset: next" I am Using Spring boot, Spring Data JP

Spring Data JPA Redis: Query by multiple values for same key? Query by Example using REGEX not supported

Please let me know if this has been asked before. I have a requirement to do some advanced filtering on data that is stored in Redis cache. Imagine there are 2

How can we assign a field of user table say id that is primary key, to another table as a primary key? using hibernate

See I dont want any mapping but what I want is just a simple thing that is.... I have two Entity Tasks(taskid,taskname.....,userId) User_Credentials(userId,pass

Field annotated with @Transient being persisted in @DataJpaTest

I'm practicing TDD, So now I'm trying to make a test that will fail for now. About to test a @Entity that don't have a field relationship mapped so far. So I'm

java.sql.SQLException: Column 'serialnumber' not found. (spring boot)

I am writing to-do list web app with spring boot. I Have 2 entities: User (fields: userid (ID), username, password Item (fields: serialnumber (ID), task, userid

How to test a repository with a user that have update rights and the test needs tot add records to the database

I use mysql and spring 5, spring-data-jpa and spring-boot and JUnit5. This must be a common problem but I don't see te sollution. I have to test a repository wi

How to add complex inner query to @Query annotaion

normal sql query which work correctly in db in sql developer passing values for bID and period. SELECT * FROM A WHERE abcID IN (SELECT abcID FROM B WHERE bID=1)

Is there a @LastAccessedTimestamp in JPA

I want to store the last read time in a Date column when ever someone tries to load or fetch(select query, findBy methods) a entity I had a look at @PostLoad as

Refresh the datasource on password rotation in SpringBoot Application

Can someone please guide me, how I can refresh the datasource whenever the password is rotated for the database. Basically I don't want any manual step to refre

Multiple list of Data comming in API when using ManyToOne Relationship

CarMake.java @Getter @Setter @EqualsAndHashCode @NoArgsConstructor @Entity public class CarMake { @SequenceGenerator( name = "car_make_sequence"

Unable to connect IBMi machine with Spring Data & JPA

Trying connect IBMi machine by using Spring Data & JPA, but it's generating the error: org.springframework.beans.factory.BeanCreationException: Error creati

Do Jpa methods execute with or without transactions by default?

I am using JPA with hibernate for mysql. I want to know whether jpa query methods will execute with or without transaction by default. I am not using transactio

Spring Data JPA with hibernate annotations

We have a large code base using Hibernate and JPA with hand-made DAO Layer. Entites are mapped with JPA annotations (javax.persistence) and if needed, hibernate

Lombok - Hibernate @OneToOne in same class - StackOverFlowError

I'm working with 2 tables: Person and City. I have a @ManyToOne relationship which worked fine. (many persons can belong to one city). Then I needed to create a

Is it possible that the changes made by a transactional method are visible in database before the transactional method ends

Two Spring boot (spring data jpa) Application A1 and Aplication A2 both read/write to a table named T1. T1 -> ID, data1, isDeleted columns My requirement is