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

Spring JPA Create ResponseEntity from findById()

In a spring boot application, I have an endpoint that returns a HTTP 200 response with an object if it exists, or a HTTP 404 reponse if not. Using spring-boot-starter-parent 1.5.7 I used to do that like this: @Autowired private GroceryRepository…
Mr. Wrong
  • 500
  • 7
  • 21
5
votes
1 answer

How to use multiple schema's in one database by using JPA + Hibernate with Spring-boot?

I need it to access 2 different schema's in one database(MySQL). I wrote two config classes here: package twodb.webfi.config; import java.util.Properties; import javax.persistence.EntityManagerFactory; import…
Durga
  • 545
  • 7
  • 21
  • 39
5
votes
1 answer

Spring specifications 'and' not working

hello! I'm trying to build a custom filter for a data grid at runtime. I'm using spring boot and vaadin 8 for data presentation. Vaadin knowledge is irrelevant to this question. How i'm doing: I built a hashmap for the filters. private…
5
votes
1 answer

How to work with alias in JPQL

I'm trying to get some values from a H2 db table. The query which does what I need is this: SELECT cast(creationDate as date) as DATE, SUM(paymentValue) as TOTAL,fxRate FROM payment group by DATE where "creationDate", "paymentValue", "fxRate" are…
M_Lude
  • 345
  • 4
  • 14
5
votes
3 answers

How to map temporary ids given by a frontend to generated backend ids?

Use Case: A user can CRUD multiple choice questions using a single page web application written in JavaScript. Creating a new question and adding some options all happens within the browser / Frontend (FE). The FE creates and uses temporary ids…
Stuck
  • 11,225
  • 11
  • 59
  • 104
5
votes
5 answers

Spring jpa native query sorting adding prefix to order by field name

I have problem with sorting. Repository method: @Query(nativeQuery = true, value = "SELECT D.ID as dealerId , D.NAME as dealerName, K.ID as kpiId, " + "K.NAME as kpiName FROM REGION R, DEALER D, KPI K " + "WHERE R.IMPORTER_ID =…
Pavel Konir
  • 51
  • 1
  • 3
5
votes
1 answer

Error when connecting Spring with Google Cloud SQL

I try to configure my Spring Boot application (deployed on App Engine) with my Google Cloud SQL instance for two days. But it doesn't work. My current project config is like that : pom.xml Note : Mysql connector java is in version 5.1.45. So I use…
5
votes
0 answers

Spring-Data JPA query method names for joined entities

I have two entities: User (it has field String userName); School (it has field Long id); In School I have: @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, targetEntity = User.class) @JoinColumn(name = "schoolId") private List
htshame
  • 6,599
  • 5
  • 36
  • 56
5
votes
3 answers

Does Spring provide stub implementation of JpaRepositories?

I am trying to unit test my Service classes that looks similiar to this: @Service public class SomeQueryService { private final SomeRepository repository; public SomeQueryService(SomeRepository repository) { this.repository…
Tomasz Bawor
  • 1,447
  • 15
  • 40
5
votes
2 answers

Does spring-data-jpa has a L2 cache implementation?

I am trying to create Repository with L2 cache with minimal setting. My database is postgresql. I start with spring-boot-sample-data-jpa-archetype project using maven. I have removed the HSQL and create a DataSource bean to connect to…
Maxi Wu
  • 1,274
  • 3
  • 20
  • 38
5
votes
1 answer

Spring Data JPA not using AttributeConverter in Spring Boot Application

I have a spring boot application that designates an AttributeConverter for an entity that converts an enum from uppercase to title case for storage in the database. I have the following entity: @Entity @Table(name = "customerleads") @Cache(usage =…
BHarman
  • 572
  • 1
  • 6
  • 15
5
votes
1 answer

SpringBoot JPA Interface's save() and delete() not working with ArrayList or Long

I am following a tutorial that uses SpringBoot 1.3. I am on the latest release of SpringBoot 2.0. I am working on creating an REST API. I need help adapting the 1.3 code to 2.0 compliance as save() and delete() now expect objects over long ids. How…
Angel
  • 311
  • 1
  • 4
  • 16
5
votes
1 answer

spring data jpa specification join fetch is not working

I am trying to use Spring Data JPA Specificaiton to query data, but I got some problem here. The Java code is as below: List studentNoticeEntityList = noticeRepository .findAll((root, criteriaQuery, criteriaBuilder) ->…
Ryan Wang
  • 51
  • 1
  • 3
5
votes
1 answer

mock a CrudRepository findById ("111").get ()

I need to mock Spring crudRepository findById("111").get() from my test class my code look like below and it return null even if I follow below steps. (1) I need to test my Service class and I created serviceTest class and used mokito and…
sashikab
  • 61
  • 1
  • 3
5
votes
2 answers

Spring Data JPA. Getting all pages from Pageable

I have a SpringBoot app and an interface that extends from CrudRepository @Query("select cps from HotelPriceSummary cps where cps.price > 5 and cps.profilePercentage >= 70 ") List findMine(Pageable pageable); I would like to know…
Nuñito Calzada
  • 4,394
  • 47
  • 174
  • 301