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
1074
votes
9 answers

What is difference between CrudRepository and JpaRepository interfaces in Spring Data JPA?

What is the difference between CrudRepository and JpaRepository interfaces in Spring Data JPA? When I see the examples on the web, I see them there used kind of interchangeably. What is the difference between them? Why would you want to use one…
kseeker
  • 10,783
  • 3
  • 15
  • 7
425
votes
9 answers

How to use OrderBy with findAll in Spring Data

I am using spring data and my DAO looks like public interface StudentDAO extends JpaRepository { public findAllOrderByIdAsc(); // I want to use some thing like this } In above code, commented line shows my intent. Can…
Prashant Shilimkar
  • 8,402
  • 13
  • 54
  • 89
334
votes
6 answers

What's the difference between Hibernate and Spring Data JPA

What are the main differences between Hibernate and Spring Data JPA? When should we not use Hibernate or Spring Data JPA? Also, when may Spring JDBC template perform better than Hibernate and Spring Data JPA?
hard coder
  • 5,449
  • 6
  • 36
  • 61
321
votes
16 answers

How do I update an entity using spring-data-jpa?

Well the question pretty much says everything. Using JPARepository how do I update an entity? JPARepository has only a save method, which does not tell me if it's create or update actually. For example, I insert a simple Object to the database User,…
Eugene
  • 117,005
  • 15
  • 201
  • 306
266
votes
3 answers

Spring CrudRepository findByInventoryIds(List inventoryIdList) - equivalent to IN clause

In Spring CrudRepository, do we have support for "IN clause" for a field? ie something similar to the following? findByInventoryIds(List inventoryIdList) If such support is not available, what elegant options can be considered? Firing…
Espresso
  • 5,378
  • 4
  • 35
  • 66
254
votes
19 answers

Spring JPA selecting specific columns

I am using Spring JPA to perform all database operations. However I don't know how to select specific columns from a table in Spring JPA? For example: SELECT projectId, projectName FROM projects
user1817436
  • 2,595
  • 2
  • 13
  • 7
219
votes
13 answers

How to add custom method to Spring Data JPA

I am looking into Spring Data JPA. Consider the below example where I will get all the crud and finder functionality working by default and if I want to customize a finder then that can be also done easily in the interface…
Sharad Yadav
  • 2,951
  • 5
  • 20
  • 18
189
votes
13 answers

Disable all Database related auto configuration in Spring Boot

I am using Spring Boot to develop two applications, one serves as the server and other one is a client app. However, both of them are the same app that function differently based on the active profile. I am using auto configuration feature of Spring…
yuva
  • 3,108
  • 4
  • 20
  • 35
188
votes
11 answers

How to test Spring Data repositories?

I want a repository (say, UserRepository) created with the help of Spring Data. I am new to spring-data (but not to spring) and I use this tutorial. My choice of technologies for dealing with the database is JPA 2.1 and Hibernate. The problem is…
user1797032
  • 2,053
  • 2
  • 13
  • 8
188
votes
13 answers

Does Spring Data JPA have any way to count entites using method name resolving?

Spring Data JPA supports counting entities using specifications. But does it have any way to count entities using method name resolving? Let's say I want a method countByName to count entities with specific name, just like a method findByName to…
YaoFeng
  • 1,889
  • 2
  • 12
  • 4
187
votes
7 answers

When use getOne and findOne methods Spring Data JPA

I have an use case where it calls the following: @Override @Transactional(propagation=Propagation.REQUIRES_NEW) public UserControl getUserControlById(Integer id){ return this.userControlRepository.getOne(id); } Observe the @Transactional has…
Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
181
votes
4 answers

What's the difference between JPA and Spring Data JPA?

I am a bit confused about the difference between Spring Data-JPA and JPA. I know about JPA that it is a specification for persisting the Java Objects to a relational database using popular ORM technology. In other words, JPA provides interfaces and…
Dhruv
  • 10,291
  • 18
  • 77
  • 126
177
votes
30 answers

Spring Data JPA - "No Property Found for Type" Exception

Well, I searched Google and found many results, but none of them was able to answer my problem. So, here it goes. I am trying to study Spring MVC and Spring Data JPA by doing a minimal implementation of pinterest clone. So, following is the parts of…
Jomoos
  • 12,823
  • 10
  • 55
  • 92
166
votes
4 answers

Difference between save and saveAndFlush in Spring data jpa

I am trying to learn spring data JPA by testing some CRUD operation via JpaRepository. I came across two methods save and saveAndFlush. I don't get the difference between these two. On calling save also my changes are getting saved into database so…
Anand
  • 20,708
  • 48
  • 131
  • 198
164
votes
6 answers

JpaRepository Not supported for DML operations [delete query]

I have written a query to delete some objects in my interface extending JPaRepository, but when I execute the query it throws an exception! Can anyone explain it for me? Query: public interface LimitRepository extends JpaRepository
Student
  • 1,643
  • 2
  • 8
  • 6
1
2 3
99 100