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?

10532 questions
953
votes
33 answers

How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds

I am trying to work with Spring Data and Neo4j. I started by trying to follow this guide linked to by the main site. In particular I based my pom.xml off of the "Hello, World!" example file. Here is a snip from my pom.xml for the plugin that is…
Andrew White
  • 50,300
  • 17
  • 108
  • 132
846
votes
6 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
  • 8,503
  • 3
  • 13
  • 7
454
votes
21 answers

Easy way to convert Iterable to Collection

In my application I use 3rd party library (Spring Data for MongoDB to be exact). Methods of this library return Iterable, while the rest of my code expects Collection. Is there any utility method somewhere that will let me quickly convert one…
Ula Krukar
  • 11,239
  • 20
  • 48
  • 65
343
votes
7 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
  • 7,156
  • 11
  • 45
  • 83
226
votes
19 answers

Spring Boot - Loading Initial Data

I'm wondering what the best way to load initial database data before the application starts? What I'm looking for is something that will fill my H2 database with data. For example, I have a domain model "User" I can access users by going to /users…
Lithicas
  • 3,003
  • 4
  • 17
  • 27
221
votes
33 answers

Spring Boot - Cannot determine embedded database driver class for database type NONE

This is the error that is thrown when trying to run my web app: [INFO] WARNING: Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name…
quarks
  • 29,080
  • 65
  • 239
  • 450
212
votes
15 answers

Unable to find a @SpringBootConfiguration when doing a JpaTest

I'm new to frameworks (just passed the class) and this is my first time using Spring Boot. I'm trying to run a simple Junit test to see if my CrudRepositories are indeed working. The error I keep getting is: Unable to find a…
Thomas Billet
  • 2,141
  • 2
  • 11
  • 12
201
votes
4 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
  • 4,130
  • 4
  • 29
  • 45
180
votes
14 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,531
  • 5
  • 18
  • 18
168
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
  • 11,959
  • 15
  • 69
  • 111
165
votes
2 answers

What is this spring.jpa.open-in-view=true property in Spring Boot?

I saw spring.jpa.open-in-view=true property in Spring Boot documentation for JPA configuration. Is the true default value for this property if it's not provided at all?; What does this really do? I did not find any good explaining for it; Does it…
Carlos Alberto
  • 5,745
  • 10
  • 44
  • 68
162
votes
20 answers

Spring boot - Not a managed type

I use Spring boot+JPA and having a problem while starting the service. Caused by: java.lang.IllegalArgumentException: Not an managed type: class com.nervytech.dialer.domain.PhoneSettings at…
user1578872
  • 5,691
  • 15
  • 69
  • 137
154
votes
8 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
  • 1,713
  • 2
  • 11
  • 8
151
votes
7 answers

How to fetch FetchType.LAZY associations with JPA and Hibernate in a Spring Controller

I have a Person class: @Entity public class Person { @Id @GeneratedValue private Long id; @ManyToMany(fetch = FetchType.LAZY) private List roles; // etc } With a many-to-many relation that is lazy. In my controller I…
Matsemann
  • 18,825
  • 18
  • 54
  • 88
142
votes
8 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
  • 10,110
  • 19
  • 64
  • 101
1
2 3
99 100