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

Spring Data JDBC org.springframework.data.mapping.MappingException: Could not read value rental_movie from result set

How to select query filter in one-to-one relationship with Spring Data JDBC ? Schema looks like this, basically 2 tables where Rental references Movie drop table if exists rental; drop table if exists movie; create table movie ( id …
Dias Abdraimov
  • 1,027
  • 12
  • 11
4
votes
1 answer

Does Spring Data JDBC support inheritance

I am working on a new project using spring data jdbc because it is very easy to handle and indeed splendid. In my scenario i have three (maybe more in the future) types of projects. So my domain model could be easily modelled with plain old java…
Thomas Lang
  • 1,285
  • 17
  • 35
4
votes
2 answers

Using query parameter of type not supported in Spring Data JDBC?

I tried to write a query method in my repository similar to this @Modifying @Query("UPDATE foo SET some_timestamp = :someTimestamp WHERE id = :id") void updateSomeTimestamp(@Param("id") long id, @Param("someTimestamp") Instant someTimestamp) When…
4
votes
1 answer

Can I use "Spring Data JDBC" with Spring Boot 1.5.x?

I have tried to figure out which version of spring-data-jdbc to use with Spring Boot 1.5.20.RELEASE (= Spring Framework 4.3.23.RELEASE) - but I can't find that info anywhere. Is it because spring-data-jdbc only work with Spring Boot 2.x / Spring…
Rasmus Lund
  • 137
  • 7
4
votes
1 answer

How to query more than one columns but not all columns with @Query but still use the Domain Data Model to map with Spring Data JDBC?

My Data model is @Getter @Setter public class Customer { @Id private ID id; @CreatedDate protected Instant createdAt; @LastModifiedDate protected Instant updatedAt; @CreatedBy protected String createdBy; @LastModifiedBy protected…
Seetha
  • 980
  • 1
  • 8
  • 27
4
votes
2 answers

How to use arrays with Spring Data JDBC

I am trying to use Spring Data JDBC for my PostgreSQL database. I defined the following beans @Data class Report { @Id private Long id; private String name; private Set dimensions; } @Data class Dimension { …
stevecross
  • 5,588
  • 7
  • 47
  • 85
4
votes
2 answers

How to handle soft-delete in Spring Data JDBC?

Is there a good way of how to handle soft-delete in Spring Data JDBC? In Spring Data JPA we can either add @Where(clause="is_active=1") annotation or extend CrudRepository or PagingAndSortingRepository. Since Spring Data JDBC doesn't support SPEL in…
Dexter
  • 98
  • 7
4
votes
1 answer

Nested data structure with Spring Data JDBC

I wanted to create a nested datastructure. Entity1 contains Objects of type Entity2 stored in a Map. Entity2 should contain a Map of Objects of Entity3. The first part, Entity1 and Entity works fine. When I add Entity3, an Exception occurs. When I…
hameiste
  • 41
  • 5
4
votes
3 answers

How to write a custom @Query in Spring Data JDBC?

In Spring Data JDBC examples, how do I write a simple query in @Query annotation? e.g. In LegoSet Repository, how do I add a simple findByName query? When I tried @Query("select * from lego_set where name = :name") List
Kevin Z
  • 41
  • 1
  • 1
  • 2
3
votes
1 answer

@CreatedDate set to null on update (spring-data-jdbc)

I am trying to use @CreatedDate in combination with spring-data-jdbc and a PostgreSQL database to track when a table entry was first created. This works when a new row is inserted (it correctly sets it as the current date), but when updating the…
Nanella
  • 105
  • 1
  • 10
3
votes
1 answer

How to log SQL statements and parameters with Spring Data JDBC

If you want to see what SQL statements Spring Data JDBC is executing, how would you do that? Since it uses bind variables, I also want to see their values in the logs.
Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
3
votes
1 answer

How can I replace using Query by Example in Spring Data JDBC?

In my view I send async request to controller with Json Data as following: { "filters":{ "someField":"someValue", "someField":"someValue", "someField":null, "someField":null, } } But data can be different. And I have…
3
votes
1 answer

Spring Data JDBC Testcontainers DataSource

With spring boot + spring data jdbc i have to wire the DataSource bean by myself. Like so: @Bean public DataSource dataSource() { HikariConfig hikariConfig = new HikariConfig(); …
Thomas Lang
  • 1,285
  • 17
  • 35
3
votes
1 answer

Spring-data-jdbc microsecond precision lost during insert of LocalDateTime type variable

It seems to me that when we run repository.save(entity) and the entity has a LocaldateTime variable mapped to a column of type timestamp(6), spring-data-jdbc (or some underlying library) is rounding off the data inserted in the column to 3 decimal…
3
votes
1 answer

Keyset Pagination for Spring Data JDBCs Pageable

AFAIK, the Pageable class supports only LIMIT/OFFSET based paging. However, while being a quite universal solution, it comes with some downsides as outlined here https://momjian.us/main/blogs/pgblog/2020.html#August_10_2020 Keyset Pagination (aka…
Mahatma_Fatal_Error
  • 720
  • 1
  • 10
  • 26
1 2
3
21 22