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
51
votes
8 answers

ImprovedNamingStrategy no longer working in Hibernate 5

I have simple spring-jpa configuration where I have configured Hibernate's ImprovedNamingStrategy. This means if my entity class has a variable userName, then Hibernate should convert it to user_name for querying the database. But this naming…
Anup
  • 556
  • 1
  • 5
  • 11
50
votes
2 answers

How do you use Spring Data JPA outside of a Spring Container?

I'm trying to wire up Spring Data JPA objects manually so that I can generate DAO proxies (aka Repositories) - without using a Spring bean container. Inevitably, I will be asked why I want to do this: it is because our project is already using…
codemaven
  • 687
  • 2
  • 6
  • 10
50
votes
6 answers

Can I use enum parameter into JpaRepository nativeQuery?

Entity looks like this: @Getter @Setter @Entity public class Application { @Id private Long id; @Enumerated(EnumType.STRING) private ApplicationStatus status; } Code works this way: public interface ApplicationRepository extends…
Tetiana Serediuk
  • 501
  • 1
  • 4
  • 5
50
votes
4 answers

Spring Data JDBC / Spring Data JPA vs Hibernate

What are the typical real life scenarios where one would choose Spring Data JDBC / Spring Data JPA vs Hibernate? I would like to understand the scenarios where either of these implementations are best suited.
Punter Vicky
  • 15,954
  • 56
  • 188
  • 315
50
votes
14 answers

Consider defining a bean of type 'service' in your configuration [Spring boot]

I get error when I run the main class. Error: Action: Consider defining a bean of type 'seconds47.service.TopicService' in your configuration. Description: Field topicService in seconds47.restAPI.topics required a bean of type…
kittu
  • 6,662
  • 21
  • 91
  • 185
50
votes
1 answer

Best way of handling entities inheritance in Spring Data JPA

I've three JPA entity classes A, B and C with the following hierarchy: A | +---+---+ | | C B That is: @Entity @Inheritance public abstract class A { /* ... */ } @Entity public class B extends A { /* ... */ } @Entity public…
Andrea
  • 15,900
  • 18
  • 65
  • 84
49
votes
1 answer

Spring data, find by property of a nested object

I have the following code: @Entity public class StudentEntity { @Id private String id; private Student student; ... } public class Student { private String name; private List grades; } public class Grade { …
DraegerMTN
  • 1,001
  • 2
  • 12
  • 21
49
votes
27 answers

Encoded password does not look like BCrypt

I am using Spring Boot, Spring Security, OAuth2 and JWT to authenticate my application, but I keep getting this nasty error and I don't have any idea what is wrong. My CustomDetailsService class: @Service public class CustomDetailsService implements…
Kunle Ajiboye
  • 723
  • 1
  • 8
  • 22
49
votes
18 answers

Spring-boot: required a bean named 'entityManagerFactory' that could not be found

I am developing a Spring Boot application using JPA and encountering this error. I am not certain if I am using the correct annotations or missing dependencies. Any help would be greatly appreciated. This is the error message 1:05:28 AM: Executing…
Zahid Anwar
  • 491
  • 1
  • 4
  • 3
49
votes
11 answers

"IllegalArgumentException: Not a managed type" in Spring Boot application

I am using Spring Boot and JPA. It is here I've got a domain that looks like this. Also it seems Entity annotation is deprecated so I am using @DynamicUpdate instead. @Data @AllArgsConstructor @NoArgsConstructor @DynamicUpdate public class Person { …
lapots
  • 12,553
  • 32
  • 121
  • 242
49
votes
4 answers

Using generics in Spring Data JPA repositories

I have a number of simple object types that need to be persisted to a database. I am using Spring JPA to manage this persistence. For each object type I need to build the following: import…
skyman
  • 2,255
  • 4
  • 32
  • 55
48
votes
6 answers

Create spring repository without entity

I want to use spring data repository interface to execute native queries - I think this way is the simplest because of low complexity. But when extending interface ex. CrudRepository I need to write T - my entity, which is not available. My…
dramcio
  • 551
  • 1
  • 5
  • 6
48
votes
3 answers

Disable Hypertext Application Language (HAL) in JSON?

Using Spring Data REST with JPA in version 2.0.2.RELEASE. How can I disable Hypertext Application Language (HAL) in the JSON ? http://stateless.co/hal_specification.html I have tried many things already, but to no avail. For example, I have set…
jplandrain
  • 2,278
  • 4
  • 24
  • 24
48
votes
2 answers

Using @Version in spring-data project

I've been working on a RESTful webservice with spring-data. A few days ago a special spring-data jpa REST framework was released. Now I noticed the ability to use @Version with this framework. Is this version generated by itself or do you need to do…
47
votes
2 answers

Spring Data JPA: Creating Specification Query Fetch Joins

TL;DR: How do you replicate JPQL Join-Fetch operations using specifications in Spring Data JPA? I am trying to build a class that will handle dynamic query building for JPA entities using Spring Data JPA. To do this, I am defining a number of…
woemler
  • 7,089
  • 7
  • 48
  • 67