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

Array contains into postgres jsonb with Spring data JDBC

Let's make a journey... What I want to achieve is SELECT * FROM people WHERE interest->'interests' ?| ARRAY['sport','cars']; into my Repository defined as public interface PeopleRepository extends CrudRepository { @Query("SELECT *…
Paolo bi
  • 141
  • 2
  • 10
2
votes
1 answer

Spring Data JDBC - Kotlin support - Required property not found for class

I'm trying to use Spring Data JDBC with Kotlin data-classes, and after adding @Transient property to primary constructor I received error on simple findById call: java.lang.IllegalStateException: Required property transient not found for class…
RomanMitasov
  • 925
  • 9
  • 25
2
votes
1 answer

Do I need to configure the beans in the example below for my Spring Data JDBC project?

Do I need to configure the beans in the example below for my Spring Data JDBC project? Even without those beans, I was able to have my repository queries working correctly. As I understand, NamedParameterJdbcOperations is used only internally to…
Ammamon
  • 467
  • 1
  • 10
  • 18
2
votes
1 answer

How do you insert with default value in spring data JDBC

CrudRepository#save doesn't allow you to use default columns. null-fields of an entity are interpreted as NULL not DEFAULT. If I use a custom @Query("INSERT INTO ... DEFAULT ..."), then I'm unable to obtain the ID of the inserted row.
2
votes
1 answer

Spring data-jdbc dependencies autoconfigures Datasource and JDBCTemplate?

In a spring test there was the question: "Would Spring Data JDBC dependency autoconfigure a Datasource and a JDBCTemplate?" I would say no because, you need a database connector dependency like h2 or oracle right to autoconfigure a datasource? And a…
2
votes
1 answer

Sharing one DB transaction by Spring Data JPA repository and Spring Data JDBC repository

First of all I want to say that I really like the Spring Data abstraction and the way how it helps me to unify handling in the persistence layer of Spring application. Recently I noticed that Spring Data JDBC came out so I decided to use it in a…
2
votes
1 answer

Validation of entities

Does Spring Data JDBC validate entities while persisting - as Spring Data JPA does with the help of hibernate? I have this scenario: Entity (more or less a copy of the actual database table) EntityDto (Data Transfer Object) with validation…
Thomas Lang
  • 1,285
  • 17
  • 35
2
votes
1 answer

How to use Spring Data JDBC without annotations?

I'm working on a new project, using concepts like clean architecture, protecting my model and business rules from external dependencies and frameworks. Also, I prefer not to use traditional ORM libraries (like JPA/Hibernate) and have choose to use…
DanielSP
  • 349
  • 3
  • 13
2
votes
1 answer

Spring data jdbc: how to use Point from org.springframework.data.geo package

I have an entity public class Arena { @Id private final Long id; @Embedded(onEmpty = Embedded.OnEmpty.USE_NULL) final Point location; } Point comes from org.springframework.data.geo package and Postgres schema to it CREATE TABLE…
Pavel Varchenko
  • 727
  • 1
  • 11
  • 21
2
votes
1 answer

Can I mock CrudRepository with Spring Data JDBC without any database using Spring Boot?

I am developing an app that uses Spring Boot 2 and Spring Data JDBC. The final app will use MySQL. I currently have a persistence layer and a service layer together with a few repositories derived from CrudRepository. For my unit tests, I want to…
2
votes
1 answer

Persisting Money with Spring Data JDBC

Let's take a following entity: class Item{ @Id Long id; String name; org.joda.money.Money price; } and a corresponding repository: interface ItemRepository extends CrudRepository { } Is it possible to persist Item in a…
marvin82
  • 216
  • 3
  • 11
2
votes
1 answer

Spring Data JDBC invert OneToMany navigation

I have an existing data scheme I'm reluctant to change. There are two entities/tables: parent and child, with child having the foreign key column parent_id. It's a 1(parent)-to-n(children) relationship. Is it possible within Spring Data JDBC to have…
2
votes
1 answer

Spring Data JDBC invert OneToOne navigation

I have an existing data scheme I'm reluctant to change. There are two entities/tables: parent and child, with parent having the foreign key column child_id. It's a 1-to-1 relationship. The problem is: the magic behind the scenes expects the child…
2
votes
2 answers

spring-data-jdbc: query containing entity with a 1-n relation

How can I write Queries for entities containing a 1-n reference? Based on the spring-data-jdbc examples I will explain it with the following unit-test: @Test public void customQuery_ReferenceMultipleInstances() { // prepare LegoSet smallCar =…
einsA
  • 797
  • 1
  • 7
  • 19
2
votes
1 answer

Using @query on CrudRepository(Spring data jdbc) with table join

I am trying spring data jdbc with @query and I met a question: If I have a query that joins 2 tables like this: @Query("select a.*, b.* from master a, detail b where b.master_id=a.id and a.id=:id") How do I get the response? The official Spring…
Jacx Wang
  • 53
  • 7