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 Identifier Processing

Use case: Connecting MySQL and oracle database Issue: If I annotate any one of the data sources as primary, it always uses the primary database Identifier processing and forms the query based on…
user1862354
  • 117
  • 11
0
votes
1 answer

Spring data jdbc - Multiple data source - Not reading data from secondry

Use case: Read data from oracle and load the same into MySQL. We are using Spring Data JDBC and OJDBC8. Issue: Always connecting to the primary data source. **application.properties** ======================= spring.datasource.mysql.jdbcUrl =…
user1862354
  • 117
  • 11
0
votes
2 answers

Using value object as ID in Spring data jdbc - unable to insert

I am trying to use the PartyId ( a value object) as Id in spring data JDBC. I am setting the value in PartyId (you can see in first screen shot below), but at time of inserting it gives following error. Debug Screen shot of cause Stack…
Ashwani Tiwari
  • 1,497
  • 18
  • 28
0
votes
1 answer

limit number of record

I use spring boot with spring data jdbc. I search to get x number of record In a interface I have @Query("select u from user where status=1"); List findUser(); Is it possible in spring data jdbc?
robert trudel
  • 5,283
  • 17
  • 72
  • 124
0
votes
0 answers

How to set multi-datasource by spring data JDBC? MySQL

I try to set multiple datasource, but just always only can get primary datasource. source Primary: @Configuration @EnableJdbcRepositories("com.xxx.repository.abc") public class AbcDataSourceConfig { @Bean @Primary …
0
votes
1 answer

Spring Data JDBC: Join on non-owned relationship

I have two aggregate root entities in my database, first an Organization with Volunteer and Moderators. Tables: create table organizations ( id uuid primary key default uuid_generate_v4(), name varchar(255) not null, slug varchar(64) …
Jesse Brands
  • 2,637
  • 8
  • 29
  • 36
0
votes
1 answer

Spring Data JDBC One-To-Many with Custom Column Name

I'm using spring-boot-starter-data-jdbc 2.4.2. In my domain aggregate I need to map a List of Strings that is populated from a column in another table. It is a legacy database so I have no control over the table and column names and need to use…
CeeTee
  • 778
  • 1
  • 9
  • 17
0
votes
1 answer

How to use many optional query parameters in Spring Data JDBC?

We want to query a table using many optional search criteria that are stored in a POJO. public class TemperatureMeterCriteria { private String state; private String title; private LocalDate date; private Year year; private…
user3849838
  • 113
  • 9
0
votes
1 answer

Does Spring Data JDBC support dynamic table names?

For a project on which we do not have control over the structure of the database which is denormalized, we must query tables whose name contains country search criteria such as : PRODUCT_FR PRODUCT_ES PRODUCT_GB Does Spring Data Jdbc support…
user3849838
  • 113
  • 9
0
votes
1 answer

How to use Spring Data JDBC across multiple databases on the same MS SQL Server instance?

I've inherited a legacy app with a massive MSSQL database instance where data model is spread across multiple databases on the same SQL Server instance. In T/SQL you can normally run queries (even joins) across databases on the same instance (SELECT…
0
votes
2 answers

Why can’t I insert an entity twice by using Spring Data Jdbc?

my entity: @Table("user") public class User { @Id private Long user_id; private String username; private String password; public User(String username, String password) { this.username = username; this.password =…
ge1mina023
  • 155
  • 1
  • 13
0
votes
1 answer

Spring data jdbc one-to-many wrong join

I'm using spring-boot 2.3.3 and spring-data-jdbc 2.0.3 to model a relationship between to elements guitar and classType. A guitar has a classType. My schema in H2 (also in MySQL) is this: CREATE TABLE class_type ( id bigint NOT NULL…
Daniel
  • 49
  • 1
  • 1
  • 10
0
votes
0 answers

Spring Data JDBC UnsatisfiedDependencyException

I wanted to move from JdbcTemplate to Spring Data JDBC. However I seem to have some misconfiguration but I cannot figure out where. The errors are "expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}" and…
werwuifi
  • 367
  • 1
  • 4
  • 15
0
votes
1 answer

How can I run custom SQL with Spring Data JDBC without @Query?

Is there a possibility to run some custom SQL query generated via 3rd party tools like e.g. jOOQ and still benefit from Spring Data JDBC mapping features i.e. @Column annotations? I don't want to use @Query annotation. class Model { @Id private Long…
mcjkwlczk
  • 145
  • 15
0
votes
2 answers

spring-data-jdbc - Why do I get DbActionExecutionException instead of DuplicateKeyException

Using : spring-boot 2.3.6.RELEASE spring-data-jdbc. postgresql I made a simple repository, extending CrudRepository, and it works fine. For example I am able to save data using this repository. I created a unique index on one of the columns, and…
baraber
  • 3,296
  • 27
  • 46