Questions tagged [spring-data-jdbc]

Spring Data JDBC is part of the Spring Data umbrella project which makes it easy to implement JDBC based repositories.

Spring Data JDBC Project page.

Github Repository.

Introduction into Spring Data JDBC or if you prefer video over text try this 10 minute video introduction.

The very important topic of Aggregates and its ramifications for Spring Data JDBC.

FAQ

324 questions
1
vote
1 answer

Spring-data-jdbc query with nullable collection

While using spring-data-jdbc and postgresql to store and search data, I was not able to come up with a query inside @Query annotation which can cover collections which are nulls. I mean the following simplified example: @Query("SELECT * FROM…
alexid
  • 11
  • 1
1
vote
2 answers

Spring Data JDBC dynamic where clauses

I have a custom search page, where i can enter up to 6 search options. This options are combined with AND so by using all filters i have 6 where clauses and so on. Two questions: Is there a way to code this dynamic where query with spring data…
Thomas Lang
  • 1,285
  • 17
  • 35
1
vote
0 answers

Spring Data JDBC @Query with Multiple IN columns

Given an entity definition like the following: public class FooBar{ @Id private long id; private Long fooNumber; private Long barNumber; ... //Other inconsequential properties } I would like to run the following…
jspillers
  • 61
  • 3
1
vote
1 answer

Spring Data JDBC Custom Naming Strategy

Is there any way to change the default column naming strategy for a referenced entity then the default (name of the class). The docs say to call the method setForeignKeyNaming(ForeignKeyNaming.IGNORE_RENAMING) on RelationalMappingContext's…
user17051329
1
vote
2 answers

Spring Data JDBC QueryCreationException. Spring Data treating my custom query name as a property name

I'm writing a custom query with Spring Data JDBC: public interface AuditRecordRepository extends CrudRepository { @Modifying @Query("DELETE FROM audit_records ar WHERE ar.created_on <= :date;") int retainDataBefore(@Param("date")…
lzy917
  • 43
  • 3
1
vote
1 answer

Server-side filtering in DB by using pagination and sorting with Spring Data JDBC

here is the situation: I need to be able to filter/sort on server side, preferably directly on DB query, not to fetch all and filter/sort on app level. Then, due to: no option to switch to JPA, we stick to JDBC pagination and sorting is…
radio
  • 897
  • 2
  • 10
  • 25
1
vote
1 answer

How to implement a "one to one" relationship with mutually exclusive alternatives in Spring Data JDBC

Given the following three tables describing an item that can be either a toy, a food or unknown: CREATE TABLE item ( id SERIAL PRIMARY KEY, name VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL CHECK (type IN ('TOY', 'FOOD',…
Marco Lackovic
  • 6,077
  • 7
  • 55
  • 56
1
vote
1 answer

@PostLoad and @PrePersist in Spring Data JDBC project

Does Spring Data JDBC have anything similar to @PostLoad and @PrePersist from Spring Data JPA?
Bit Wise
  • 29
  • 4
1
vote
0 answers

Spring data JDBC connections leaks when doing a transaction

I'm experiencing connection leaks with my spring data jdbc postgres app. Basically for my calls that are not called in a transaction the connection is acquired and released to the pool. However when it comes to transactional calls connections are…
1
vote
1 answer

Query different models from the same set of tables with spring-data

I would like to know how to best use Spring Data to query the same set of database tables differently depending on the use cases. Scenario: Products can be bought by Users via Orders. Each Product can either be a standalone product or consist of…
chrsi
  • 992
  • 9
  • 24
1
vote
1 answer

Spring data jdbc with multiple data sources and multiple dialects

I have a spring boot application that uses spring data jdbc and connects to two databases. One of them is postgres and one is oracle. I access them via jdbc repositories (org.springframework.data.repository.Repository). That works very well in…
mio
  • 562
  • 5
  • 19
1
vote
1 answer

Lock annotation in Spring-data-jdbc

This reference documentation from spring.io states claims that Spring Data JDBC supports a @Lock annotation. Spring Data JDBC supports locking on derived query methods. To enable locking on a given derived query method inside a repository, you…
findusl
  • 2,454
  • 8
  • 32
  • 51
1
vote
1 answer

How to change order of callbacks in spring data jdbc?

How to change order of callbacks in spring data jdbc? Primary, order, dependsOn used, didn't help. @Bean AfterDeleteCallback test() { return (document) -> { log.info("test"); return document; …
sayf21
  • 11
  • 2
1
vote
1 answer

"java.lang.IllegalArgumentException: Cannot query by nested property" when using query derivation for property on nested entity

This is a follow-up question to this: Reference to another aggregate vs. sub-entity I have the following Aggregate: Evaluation (root) | |__Employee (entity) | |_SupervisorId (value object) | |__Year (value object) | |__ExpiryDate (value object) I…
1
vote
1 answer

Reference to another aggregate vs. sub-entity

Let's assume we have three aggregates: Employee Evaluation Contract Both Evaluation and Contract are referencing Employee (using an AggregateReference or the ID itself). The problem is that both Evaluation and Contract very regularly need specific…