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

How to create a non-persistent Field in an JPA Entity?

I have an Entity called Users that have login, name and department as fields that are stored in Users table. My Spring-Boot configuration defines the departments that gives the system manager role for users in this application. The key problem is…
NaN
  • 8,596
  • 20
  • 79
  • 153
5
votes
1 answer

Spring-Data Repository @Query by class with generic class

assuming I have the following entities: @Entity public class Word { ... } @Entity public class Noun extends Word { ... } @Entity public class Verb extends Word { ... } (Plus the usual Disriminator- and Join-Strategy stuff, simply assume that the…
Florian Schaetz
  • 10,454
  • 5
  • 32
  • 58
5
votes
3 answers

Change Multitenancy sessions manually

I need to create a multitenanacy application with ability to switch between schemas inside my java-code (not based on a user request). I've read…
Ermintar
  • 1,322
  • 3
  • 22
  • 39
5
votes
1 answer

CriteriaBuilder: join one-to-many with ON clause

Suppose you the following OneToMany relationships: School->Student->ScientificWork. Now you want to select all Schools that have Student with name 'John' and his scientific job is called 'Black Holes'. I do it like the following, but for some…
VB_
  • 45,112
  • 42
  • 145
  • 293
5
votes
2 answers

Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' threw an exception

I've been trying to solve this "destory method exception" with online tips but have no success. Here is the error message: 2017-10-16 15:58:13.234 ERROR 12276 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Destroy method on bean…
Gene Xu
  • 609
  • 1
  • 8
  • 18
5
votes
3 answers

single custom deserializer for all objects as their ids or embedded whole objects during POST/PUT

@Entity public Product { @Id public int id; public String name; @ManyToOne(cascade = {CascadeType.DETACH} ) Category category @ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.DETACH} ) Set
Michail Michailidis
  • 11,792
  • 6
  • 63
  • 106
5
votes
3 answers

How to save same object multiple times use Spring Data?

I want save an object multiple times, the code below can not work: for(int i = 0; i < 5; i++) { repository.save(object); } Then I change the source to: List objectList = new ArrayList<>(); for(int i = 0; i < 5; i++) { …
fish
  • 2,173
  • 2
  • 13
  • 18
5
votes
2 answers

JpaRepository with Enum: findAllByOfferState_ACTIVE. NoSuchElementException

I want to get all offers with (where) OfferState equals ACTIVE - is it possible using Spring Data with only method name or I must use @Query? @Repository public interface OfferRepository extends JpaRepository { Page
el_konrad
  • 1,211
  • 2
  • 11
  • 12
5
votes
0 answers

Load CSV file in Spring JPA using @Query

I'm trying to upload a CSV file directly into the database using Hibernate + Spring Data JPA. When I run this command con MySQL shell, everything works fine: LOAD DATA LOCAL INFILE '' INTO TABLE debtor_csv FIELDS TERMINATED BY ';' LINES TERMINATED…
fferrin
  • 888
  • 2
  • 12
  • 29
5
votes
1 answer

How To Make Relations Between Two Entities From Different Microservices In Spring Boot?

I am trying to make a simple Spring Boot web app using Microservice Architecture. I have two microservices with entities as defined below: Microservice 1 : @Entity public class Article { @Id @GeneratedValue(strategy =…
Milad
  • 77
  • 2
  • 5
5
votes
1 answer

Spring Boot closes hibernate session on shutdown - before @Async methods are finished

I have a problem with a spring boot application that closes the EntityManager/session on shutdown before @Async tasks (that use the EntityManager) are finished. There are 2 classes relevant for this problem: Scheduler The scheduled method reserves a…
5
votes
2 answers

How many times Database is hit in Spring DATA JPA's save(Iterable entities)

I have the following lines of code: @RequestMapping(value="/persons",method = RequestMethod.POST) @ResponseBody public ResponseEntity> saveUsers(@RequestBody List persons) { persons = (List)…
Avik Dutta
  • 143
  • 12
5
votes
1 answer

Pass port number from docker-maven-plugin to spring property

I'm developing Spring Data JPA project that targets a MySQL database, and I want to run end-to-end integration tests from Maven. So far, I've configured io.fabric8.docker-maven-plugin to spin up a MySQL container during pre-integration-test phase.…
Lewis Watson
  • 543
  • 1
  • 4
  • 15
5
votes
1 answer

Spring Data JPA: Query for Field in List of Objects

I'm looking for the correct method name to find all Documents with a given Target's type: public class Document { @Indexed(name = "targets") private List targets; public class Target { private String value; …
user3105453
  • 1,881
  • 5
  • 32
  • 55
5
votes
2 answers

How can i get current session used by @Transactional annotation in Hibernate/Spring Data?

I have been executing stored procedure using Callable statement from datasource. Now this procedure has to read data from an insert query executed just before SP execution in same service. so this creates a problem as the whole service is wrapped…
Philip George
  • 83
  • 2
  • 6
1 2 3
99
100