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
0
votes
1 answer

Spring Data JDBC is unable to map the column value to the property of the entity when the column name is reserved keyword

I'm facing a similar issue as described in this thread, but my case involves using Spring Data JDBC instead of JPA. I have an entity defined as follows: @Table("TEST_TABLE") @Data public class TestTableEntity { @Id private int id; …
Newbie
  • 1,584
  • 9
  • 33
  • 72
0
votes
1 answer

SpEL #{#entityName} alternative in Spring Data JDBC

I am extending a base repository with shared queries across entities but unfortunately spring does not support derived delete queries in spring data jdbc. I had to write a custom query in all my repositories: @Modifying @Query("DELETE FROM table…
user17051329
0
votes
1 answer

spring data jdbc BeforeConvertCallback is not working anymore from 3.0.6 onwards

In spring data jdbc bundled with spring boot 3.0.5 I could generate an Id by using the BeforeConvertCallback: @Configuration @EnableJdbcRepositories class JdbcConfig extends AbstractJdbcConfiguration { @Bean BeforeConvertCallback
0
votes
0 answers

How to wire my custom constructed DataSource into CrudRepository?

I'm working on data migration from SQL Server to PostgreSQL. I'm planning to switch the data source using a feature toggle to reduce the migration risk. I've got good idea how to return appropriate DataSource based on the feature toggle from…
sumek
  • 26,495
  • 13
  • 56
  • 75
0
votes
0 answers

how to use spring data rest with multiple boot apps

I have two aggregate roots, Account which holds id, name and Alert which holds id, title and Account(@ManyToOne). Using spring boot with data-jpa and data-rest I can see the full magic in swagger-ui. Now I want to achieve the same result while…
0
votes
1 answer

spring data jdbc store and retrieve LocalDateTime as java.sql.Timestamp instead of java.sql.Date

I use spring-data-jdbc to store and retrieve data from the underlying repository. I have a date-time field that has to be stored with hour, minutes and seconds. So in my entity the field is declared as LocalDateTime. My understanding is that the…
stessy
  • 13
  • 2
0
votes
1 answer

Spring Data JDBC Interface Projection with nested property

I have this DTOs (data transfer object): public record ProjectsDto(long id, String projectName, String contact, String fundingCode, LocalDate runtimeFrom, LocalDate runtimeTo, String costUnit, String chapter, String unit,…
Thomas Lang
  • 1,285
  • 17
  • 35
0
votes
2 answers

spring data JDBC generates invalid queries

Here is my table structure. I am using spring-boot-starter-data-jdbc 3.0.3. I mapped these tables like below. @Table("ticket") public class Ticket { @Id private int id; private String subject; private TicketType ticketType; //…
0
votes
1 answer

Using org.springframework.data.jdbc.core.convert.SqlGenerator in my own package throw composition design

I'm currently working on a project that utilizes Spring Data JDBC custom repository. In my custom repository, I have implemented my own DataAccessStrategy, AggregateRoot, AggregateExecutor, and SqlParameterSource to generate SQL scripts. However, I…
0
votes
1 answer

Generic CustomRepository Implementation with dynamic Query using Spring Data JDBC

@Repository public interface StudentRepository extends CrudRepository, CustomRepository { } @Repository public interface EmployeeRepository extends CrudRepository ,CustomRepository
jimp a
  • 1
0
votes
1 answer

Why does Spring data jdbc run a select statement when inserting?

I have a deadlock that baffles me. It happens in my spring application upon inserting into a Table without an active transaction. I use the save method on the SimpleJdbcRepository. This question is not about solving the Deadlock but about why it…
findusl
  • 2,454
  • 8
  • 32
  • 51
0
votes
1 answer

Using junction tables created in schema within Spring Boot JDBC

I'm trying out pre-defining my database structure using SQL schema and then utilising it within my Kotlin code. I'm using Spring Boot and Spring Data JDBC. Here's what I currently have so far: My User class: data class User( @Column(name =…
JamieRhys
  • 206
  • 6
  • 24
0
votes
1 answer

Spring initialzr - At SQL category, what do I choose between JDBC API, Spring Data JPA and Spring Data JDBC

I'm doing a learning project and I want to create an API. I will be using PostgreSQL. I'm setting up my project with Spring Initializr and I'm a bit confused regarding the SQL options. Which should I choose? I tried to research the differences…
0
votes
1 answer

How using @InsertOnlyProperty with Spring Boot 2.7

I'm going to use @InsertOnlyProperty with Spring Boot 2.7 as it will take time for us to migrate to Spring Boot 3.0! So I'm going to create my DataAccessStrategy based on the DefaultAccessStrategy and also override the SqlParametersFactory so that I…
Khusayn
  • 37
  • 6
0
votes
1 answer

How get entity class type from sub aggregation Set collection

I realize custom repository and try because we use Spring Data Jdbc 2.7 which is not supporting InsertOnlyProperty and in SQL generation I try to get class of sub aggregation for using in context.getRequiredPersistentEntity. How can I get it from…
Khusayn
  • 37
  • 6