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

Primary key violation when inserting child entity

DB Schema (H2 database): create table book ( id_book bigint auto_increment not null primary key, title varchar(255) not null, id_author bigint not null, id_genre bigint not null ); create table comment ( id_comment bigint…
1
vote
1 answer

How to start Spring Data JDBC based app without db?

I'm trying to build a small REST API with Spring Boot that has connectivity to Database using Spring Data JDBC (with Hikari CP). The app should run on container environment like k8s. At moment I'm facing a problem, when the app does not have db…
Leandro Loureiro
  • 403
  • 3
  • 13
1
vote
1 answer

Spring Data JDBC: Invalid API Usage When Calling Oracle Stored Function

I am attempting to call an Oracle stored function via Spring Data JDBC (NOT JPA but JDBC) with the @Query annotation: @Repository public interface UserRepository extends CrudRepository{ @Query(value="? = call…
Jason
  • 3,943
  • 12
  • 64
  • 104
1
vote
1 answer

Spring JPA + JDBC in same transaction

If a transaction is started using Spring's @Transactional, is there any issue using a combination of JPA and JDBC within this transaction? Meaning, will the transactional handling still work as expected where if an rollback happens, it will rollback…
Bryan Bende
  • 18,320
  • 1
  • 28
  • 39
1
vote
1 answer

Derived delete query in Spring Data JDBC not working

I've put a derived query on a CrudRepository that should delete all entities with a given businessId (which is not the primary key but just another, non-unique column), of which there can be many. In my SpringDataJdbcTest test, I…
user1100243
  • 21
  • 1
  • 2
1
vote
1 answer

Spring Data JDBC deletes all entries and inserts them again

I am currently playing around with the Spring Data Jdbc framework and I don't understand the following behaviour: When I have an aggregate root that stores a list of children and I add one child, it deletes all children and inserts them again. This…
Benjamin_Ellmer
  • 87
  • 1
  • 1
  • 6
1
vote
1 answer

Couldn't determine JDBCType for class + Spring data jdbc

long countActionByStateIn(ActionState[] states); // works // throws Couldn't determine JDBCType for class com.example.ActionEnum @Query("Select * from action WHERE (COALESCE(:states, NULL) IS NULL OR state IN (:states))") public List
Parmod
  • 1,213
  • 1
  • 10
  • 18
1
vote
1 answer

Spring Data Jdbc and Oracle21c

for my latest assignment I'm developing a Spring boot application which will connect with an Oracle 21c database. The feature of the oracle release we're interested in is the native JSON data type called OSON (reference here: Oracle 21c JSON data…
drew1927
  • 11
  • 1
1
vote
1 answer

spring-data-jdbc bad sql grammar on update

In spring-data-jdbc 2.3.2 with 2.6.4 data-jdbc starter. I am seeing the following output. Not clear if this is my error in a model layer or an issue with the framework. This happens when the root aggregate tries to get updated because of a…
mabreu0
  • 80
  • 2
  • 8
1
vote
1 answer

@Query returning `Couldn't find PersistentEntity` when querying one column with null value

Edited: I also tested in the version 2.6.4 and still happens I just upgraded spring-boot from 2.5.7 to 2.6.1 and I notice a change of behavior in a specific query. I'm trying to load only a specific column in a query, and when it's value in DB is…
aquilesb
  • 2,182
  • 1
  • 19
  • 19
1
vote
2 answers

Spring Boot Data JDBC field as json value

I have a model which i want to save to database. @Data public class Model { @Id private UUID id; private String name; private ModelSettings settings; @Data static class ModelSettings { boolean fuelEngine; …
PirateNinja
  • 111
  • 7
1
vote
1 answer

Spring boot data jdbc implement Many to Many relationship with same entity

How can I model many to many relationship with same entity with spring data jdbc. I have a scenario where a task can depend on several other task and at the same time the task has dependants but it is same object. I have done this previously with…
omexIT
  • 111
  • 8
1
vote
1 answer

Spring Data JDBC cascade creation

Is it possible to cascade creation in Spring Data Jdbc as in Spring Data JPA for OneToMany and ManyToMany relationships? If not, what would be the strategy then ? @Table("orders") public class Order { @Id private UUID id; …
1
vote
0 answers

Spring Data JDBC - how to have dynamic db schemas for entities known only at run time?

I have a database with multiple schemas (one schema per customer), with each schema having the same tables. This is a common pattern in multitenant apps. I'm trying to use Spring Data JDBC to access these tables. I see how you can specify a…
marathon
  • 7,881
  • 17
  • 74
  • 137
1
vote
1 answer

Spring Data JDBC one-to-many relation causes lots of log warnings

Summary: Spring Data emits warnings as it SELECTs the the same column twice. The warning is: (...) WARN o.s.d.j.core.convert.ResultSetAccessor : ResultSet contains id multiple times This is spring-boot-starter-data-jdbc via Spring Boot 2.5.5…