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
3 answers

Foreign key is always null in one to many relation - Spring Boot Data with JPA

I have two entity classes Country and Language having bi-directional one to many relationship. Below are the entity classes: @Entity @Table(name = "COUNTRY") public class Country { @Id @GeneratedValue @Column(name = "COUNTRY_ID") …
Pawan Kumar
  • 259
  • 1
  • 6
  • 17
5
votes
1 answer

How do database connections get managed for Spring Data JPA repositories?

I have a question about how Spring Data repositories are handling the datasource connections. Assuming Spring Data repositories open and close the connection and the connection when the method executes, how does the transaction started by declaring…
Magg
  • 61
  • 1
  • 4
5
votes
0 answers

How to configure Spring Data Rest to return A Json-LD or Siren media type instead of HAL

I have been struggling to find any examples of how one could override the default Spring Boot Data Rest JpaRepository behavior to return something other than a HAL response. I have found that both Siren and Json-LD can meet the requirements but not…
5
votes
2 answers

Multiple representations of the same entity in SpringBoot 2.0.4

I have a basic SpringBoot 2.0.4.RELEASE app. using Spring Initializer, JPA, embedded Tomcat, Thymeleaf template engine, and package as an executable JAR file. I have a User object with roles: @Entity @Table(name="t_user") public class User…
Nuñito Calzada
  • 4,394
  • 47
  • 174
  • 301
5
votes
0 answers

Spring DataJpaTest transactional behavior for Nested JUnit 5 tests

I am using Spring Boot 2 with JUnit 5, writing a DataJpaTest for a JpaRepository. The tests are run against a real PostgreSQL database (not embedded, not in-memory). According to the documentation, by default each test is in a transaction and gets…
Nikolaos Georgiou
  • 2,792
  • 1
  • 26
  • 32
5
votes
2 answers

JBoss EAP 7.1 Spring-Data-JPA CDI Extension

We have an app that uses Spring Data JPA repositories to inject into EJB's. Spring's org.springframework.data.jpa.repository.cdi.JpaRepositoryExtension does the magic. It looks for an EntityManager in CDI, saves it for later use, looks for Spring…
Cary
  • 61
  • 6
5
votes
4 answers

JPA 'where in' to be considered only if List passed as parameter has elements

I have one query that should filter based on various parameters; one of those parameters is a list. If there are entries in the list, there should be a filtering based on the entries; but if the list is empty/null, there shouldn't be any filtering…
Random42
  • 8,989
  • 6
  • 55
  • 86
5
votes
1 answer

405 Method not allowed despite exposing all methods when using RepositoryRestConfiguration.disableDefaultExposure()

I don't want to expose my repositories by default and it looks like RepositoryRestConfiguration.disableDefaultExposure() does exactly what I want; however I get a 405 response when calling /{respository/{id}. I have marked all of the methods on my…
jebbench
  • 283
  • 1
  • 4
  • 12
5
votes
4 answers

UnknownEntityTypeException: Unable to locate persister

I want to use JPA with Spring on Wildfly. I tried this…
Peter Penzov
  • 1,126
  • 134
  • 430
  • 808
5
votes
1 answer

JPAQuery with Spring Pageable

I'd like to use org.springframework.data.domain.Pageable with com.querydsl.jpa.impl.JPAQueryis there a way or is there a solid workaround how to make Pageable work with JPAQuery?
Mihkel L.
  • 1,543
  • 1
  • 27
  • 42
5
votes
1 answer

Spring Data JPA Could not instantiate persister org.hibernate.persister.entity.JoinedSubclassEntityPersister

I faced a problem using @Inheritance(strategy = InheritanceType.JOINED), i have four classes envolved in this problem, Person (Superclass) , Supplier(child class), Client (child class), Transaction ( have a relathion with Client and Supplier…
abdou amer
  • 819
  • 2
  • 16
  • 43
5
votes
1 answer

TOP [N] Records Group By per user query in the best possible way

I faced an interesting problem today: Lets suppose the following conditions 1. There are n number of users 2. The system collects GPS coordinates of each driver as they move 3. We have to query last 10 GPS Coordinate records per user sorted by …
Kalyan Pradhan
  • 1,415
  • 3
  • 19
  • 34
5
votes
1 answer

The method findOne(Example) in the type QueryByExampleExecutor is not applicable for the arguments (Long)

The find methods not working for me but in other project work fine . import org.springframework.data.jpa.repository.JpaRepository; import com.example.demo.entities.Contact; public interface ContactRepository extends JpaRepository
M.SAM SIM
  • 85
  • 1
  • 5
5
votes
0 answers

Auto-partitioning/batching large Spring Data JPA in-clauses

A common pattern is causing problems when the input lists grow large. Many Spring Data interfaces that extend org.springframework.data.jpa.repositoryJpaRepository declare queries that use an in-clause. A simplified example: @Query("SELECT…
JoeG
  • 7,191
  • 10
  • 60
  • 105
5
votes
2 answers

Debugging Memory leak - org.hibernate.engine.StatefulPersistenceContext

There is a service that connects to Oracle DB for reading data and it uses Hibernate-3.6 and SpringData-JPA-1.10.x. Heap dumps are getting generated frequently which results in out of memory on the hosts. After analyzing few heapdumps using Eclipse…
Saravanan
  • 604
  • 1
  • 8
  • 20