Questions tagged [spring-data-jpa]

Spring Data - JPA is part of the Spring Data umbrella project which makes it easy to implement JPA based repositories

Spring Data JPA, part of the larger family, makes it easy to easily implement based repositories. This module deals with enhanced support for based data access layers. It makes it easier to build Spring-powered applications that use data access technologies.

is based on the concepts of Aggregates, Aggregate Roots and Repositories. It works best if these concepts are considered when you design your domain model. You might want to look into "Advancing Enterprise DDD" to learn what that actually means.

Please note that Spring Data doesn't try to abstract over the underlying technology. This means as a user you still have to understand it. In the case of Spring Data JPA this means you need to understand JPA in order to properly work with Spring Data JPA. This applies especially to the workings of the 1st level cache.

Useful links

Popular Questions

What is Spring Data JPA (good for)

Common questions

22458 questions
5
votes
2 answers

Spring Data JPA loads one to one relationship in two queries

I have following classes: @Data @Entity @Table(name = "user_info") public class UserIdentity implements UserDetails { @Id private Long id; private String username; private String password; private String facebookId; private String…
Alex
  • 1,940
  • 2
  • 18
  • 36
5
votes
3 answers

JPA One to One mapping with inheritance: 2 Queries for what should be one

I have a one to one relationship between a Media entitiy and a MediaAnalysis entity where the Media entity is an abstract base class: News Report Entity @Entity @DiscriminatorValue("N") public class NewsReport extends Media { @Column(name =…
Eduardo
  • 6,900
  • 17
  • 77
  • 121
5
votes
1 answer

2 Hikari CPs with different datasource configurations?

Has anyone successfully configured two hikari connection pools with different datasources in a spring boot application? How do I do it using application.properties?
gcpdev-guy
  • 460
  • 1
  • 10
  • 23
5
votes
0 answers

Data base pessimistic locks with Spring data JPA (Hibernate under the hood)

I need some help with pessimistic entity locking. I'm using PostgreSQL and Spring data JPA (hibernate 5 under the hood) in my application. So, I want to show a task I've faced with. I have some user accounts with money: @lombok.Data //Used to…
Bohdan Petrenko
  • 997
  • 2
  • 17
  • 34
5
votes
1 answer

hibernate lazy load exception after deep clone using Serialization

TLDR: I am using Spring-jpa and Hibernate in my project, My problem occured only after I'm trying to get a List of objects that defined as Lazy in the entity that I deep cloned using org.apache.commons.lang3.SerializationUtils.clone() method. I get…
Ron Badur
  • 1,873
  • 2
  • 15
  • 34
5
votes
5 answers

Spring Dependency Injection into JPA entity listener

I need to have a Spring dependency injected into a JPA entity listener. I know I can solve this using @Configurable and Spring's AspectJ weaver as javaagent, but this seems like a hacky solution. Is there any other way to accomplish what I'm trying…
Krzaku
  • 186
  • 4
  • 16
5
votes
1 answer

Using Spring JPA to setup a Aggregate Function for STRING_AGG with Postgresql for a Group_By

I am trying to setup a repository call to retrieve the ID's of a list of test results ids used in the GROUP_BY. I can get this to work using createNativeQuery but I am unable to get this to work using Spring's JPA with the FUNCTION call. …
ALM
  • 2,555
  • 7
  • 31
  • 45
5
votes
1 answer

Automatically Add criteria on each Spring Jpa Repository call

I'm writing a library that wraps the JpaRepository interface of Spring Data Jpa because I want to add the same criteria automatically to all JpaRepository DB calls (something like and where t > something). For example findById function of…
Ron Badur
  • 1,873
  • 2
  • 15
  • 34
5
votes
1 answer

Spring Data JPA save list entity return list in same the order?

Does the method in Spring-Data-JPA's CrudRepository Iterable saveAll(Iterable entities) return list in the same order ?
tsarenkotxt
  • 3,231
  • 4
  • 22
  • 38
5
votes
0 answers

Order by multi-column that include sort by field collection size spring jpa repository

I don't think it is duplicate of Order by count using Spring Data JpaRepository. Let me explain my problem:- I have a domain object called Account that consists of name, status, list of group objects, list of membership objects. for…
Vikas Verma
  • 3,626
  • 6
  • 27
  • 40
5
votes
1 answer

Understanding Optional.map()

Reviewing an example use of Optional where the optional is first loaded with a database call and then mapped to a Spring security UserDetails instance. The code looks like this: Optional user =…
Ole
  • 41,793
  • 59
  • 191
  • 359
5
votes
1 answer

Why Spring Data JPA's save() is slow when called on a single record vs calling it on a list of records?

I'm experiencing a major time reduction when using save function from SimpleJpaRepository on a single record vs calling save on a list of records. The loop below takes 10 times longer than the list. for (Record r : csvRecords) { …
Oleg
  • 1,479
  • 3
  • 21
  • 42
5
votes
6 answers

ClassNotFoundException CrudRepository

I'm reading the JPA docs on spring, and i'm trying to restructure my code. What i have now: BrewerRepository @Repository public class BrewerRepository { @PersistenceContext(name = "vivesPU") private EntityManager entityManager; public…
vixero
  • 514
  • 1
  • 9
  • 21
5
votes
1 answer

Dealing with m-to-n relations in @RepositoryRestResource

Preface I want to create a sub-resource of another resource in one call. These resources have a @ManyToMany relationship: Users and Groups. I do not want to create first a user, then the group and after that the relation as it is shown in Working…
Stefan Falk
  • 23,898
  • 50
  • 191
  • 378
5
votes
2 answers

JPA, Hibernate validators - email validator not applying on String

I'm trying to figure out how to validate DTO in my controller Stack: Spring boot 1.5.4, Spring Data JPA, Hibernate Validation 5, PostgreSQL The problem is that I'm still getting exception about missing validators. Any…
vlcik
  • 911
  • 4
  • 20
  • 33
1 2 3
99
100