Questions tagged [spring-data]

Spring Data is an umbrella open source project which contains many subprojects that are specific to a given database. The projects are developed by working together with many of the companies and community that are behind these exciting technologies.

The primary goal of the Spring Data project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services as well as provide improved support for relational database technologies.

This is an umbrella project which contains many subprojects that are specific to a given database. The projects are developed by working together with many of the companies and developers that are behind these exciting technologies.

Resources

Spring Data modules and specific tags

Noteworthy Questions and Answers

Are you supposed to have one repository per table in JPA?

11873 questions
158
votes
9 answers

setMaxResults for Spring-Data-JPA annotation?

I am trying to incorporate Spring-Data-JPA into my project. One thing that confuses me is how do I achieve setMaxResults(n) by annotation ? for example, my code: public interface UserRepository extends CrudRepository { …
smallufo
  • 11,516
  • 20
  • 73
  • 111
158
votes
1 answer

How are Spring Data repositories actually implemented?

I have been working with Spring Data JPA repository in my project for some time and I know the below points: In the repository interfaces, we can add the methods like findByCustomerNameAndPhone() (assuming customerName and phone are fields in the…
Vasu
  • 21,832
  • 11
  • 51
  • 67
147
votes
9 answers

Spring Data JPA map the native query result to Non-Entity POJO

I have a Spring Data repository method with a native query @Query(value = "SELECT g.*, gm.* FROM group g LEFT JOIN group_members gm ON g.group_id = gm.group_id and gm.user_id = :userId WHERE g.group_id = :groupId", nativeQuery = true) GroupDetails…
alexanoid
  • 24,051
  • 54
  • 210
  • 410
135
votes
3 answers

What's the difference between Spring Data's MongoTemplate and MongoRepository?

I need to write an application with which I can do complex queries using spring-data and MongoDB. I started using the MongoRepository but struggled with complex queries to find examples or understand the Syntax. I'm talking about queries like…
Christopher Armstrong
  • 3,477
  • 6
  • 34
  • 40
134
votes
9 answers

Spring Data: "delete by" is supported?

I am using Spring JPA for database access. I am able to find examples such as findByName and countByName, for which I dont have to write any method implementation. I am hoping to find examples for delete a group of records based on some…
curious1
  • 14,155
  • 37
  • 130
  • 231
128
votes
22 answers

Can't Autowire @Repository annotated interface in Spring Boot

I'm developing a spring boot application and I'm running into an issue here. I'm trying to inject a @Repository annotated interface and it doesn't seem to work at all. I'm getting this error org.springframework.beans.factory.BeanCreationException:…
visst
  • 1,351
  • 2
  • 11
  • 10
128
votes
10 answers

Spring data JPA query with parameter properties

What is the simplest way of declaring a Spring data JPA query that uses properties of an input parameter as query parameters? For example, suppose I have an entity class: public class Person { @Id private long id; @Column private…
Kkkev
  • 4,716
  • 5
  • 27
  • 43
126
votes
5 answers

Spring Data JPA find by embedded object property

I want to write a Spring Data JPA repository interface method signature that will let me find entities with a property of an embedded object in that entity. Does anyone know if this is possible, and if so how? Here's my code: @Entity @Table(name =…
CorayThan
  • 17,174
  • 28
  • 113
  • 161
125
votes
9 answers

Spring Boot and how to configure connection details to MongoDB?

Being new to Spring Boot I am wondering on how I can configure connection details for MongoDB. I have tried the normal examples but none covers the connection details. I want to specify the database that is going to be used and the url/port of the…
Marco
  • 15,101
  • 33
  • 107
  • 174
123
votes
1 answer

crudrepository findBy method signature with multiple in operators?

I have an Entity Class like this: @Entity @Table(name = "EMAIL") class Email{ @Id @Column(name = "Id") Long id; @Column(name = "EMAIL_ID") String emailId; @Column(name = "PIN_CODE") String pincode; } How to write findBy…
Venkata Rama Raju
  • 1,325
  • 2
  • 10
  • 15
120
votes
10 answers

Call another rest api from my server in Spring-Boot

I want to call another web-api from my backend on a specific request of user. For example, I want to call Google FCM send message api to send a message to a specific user on an event. Does Retrofit have any method to achieve this? If not, how I can…
Mahdi
  • 6,139
  • 9
  • 57
  • 109
119
votes
5 answers

Missing CrudRepository#findOne method

I am using Spring 5 in my project. Until today there was available method CrudRepository#findOne. But after downloading latest snapshot it suddenly disappeared! Is there any reference that the method is not available now? My dependency list: apply…
Andrii Abramov
  • 10,019
  • 9
  • 74
  • 96
117
votes
20 answers

Spring Data and Native Query with pagination

In a web project, using latest spring-data (1.10.2) with a MySQL 5.6 database, I'm trying to use a native query with pagination but I'm experiencing an org.springframework.data.jpa.repository.query.InvalidJpaQueryMethodException at startup. UPDATE:…
Lasneyx
  • 2,110
  • 2
  • 17
  • 21
116
votes
5 answers

Spring Data JPA difference between findBy / findAllBy

Is there any difference when using Spring Data JPA keywords between: List findBySomeCondition(); and List findAllBySomeCondition();
Nikita
  • 1,465
  • 3
  • 15
  • 17
116
votes
5 answers

Spring DAO vs Spring ORM vs Spring JDBC

I was going through data access technologies supported by Spring, and I noticed that it mentions multiple options and I am not sure about the difference among them: Spring-DAO (http://docs.spring.io/spring/docs/2.0.8/reference/dao.html) Spring-ORM…
Pat
  • 2,223
  • 4
  • 19
  • 25