Files
spring-data-relational/spring-data-jdbc
Jens Schauder 08710d8e16 Reuse custom converters from AggregateReferenceConverters.
Let the AggregateReference converters now receive also custom converters as delegates.
Remove the ArrayToObjectConverter which just uses the first element of the array from the DefaultConversion service.

This does NOT solve the underlying problem, of having two DefaultConversionServices at work.
One is in the store conversion, one constructed in the AbstractRelationalConverter.
Although it looks like they get merged, the former contains converters, using that ConversionService as a delegate.

Attempts were made to move AggregateReferenceConverters out of the store converters and just register them directly,
but then no custom read/write targets are detected, leading to failed conversions.
The same problem prevents a registration in CustomConversions as a Function<ConversionService, GenericConverter> or similar, which would allow late registration.
The problem here is that custom read/write targets require the function to get evaluated, before custom read/write targets can be determined.

Closes #1750
Original pull request: #1785
2024-05-15 14:56:58 +02:00
..
2024-04-12 10:52:59 +02:00
2023-10-16 11:01:23 +02:00

= Spring Data JDBC

The primary goal of the https://projects.spring.io/spring-data[Spring Data] project is to make it easier to build Spring-powered applications that use data access technologies. *Spring Data JDBC* offers the popular Repository abstraction based on JDBC.

It aims at being conceptually easy.
In order to achieve this it does NOT offer caching, lazy loading, write behind or many other features of JPA.
This makes Spring Data JDBC a simple, limited, opinionated ORM.

== Features

* Implementation of CRUD methods for Aggregates.
* `@Query` annotation
* Support for transparent auditing (created, last changed)
* Events for persistence events
* Possibility to integrate custom repository code
* JavaConfig based repository configuration by introducing `EnableJdbcRepository`
* Integration with MyBatis

== Getting Help

If you are new to Spring Data JDBC read the following two articles https://spring.io/blog/2018/09/17/introducing-spring-data-jdbc["Introducing Spring Data JDBC"] and https://spring.io/blog/2018/09/24/spring-data-jdbc-references-and-aggregates["Spring Data JDBC, References, and Aggregates"]

There are also examples in the https://github.com/spring-projects/spring-data-examples/tree/master/jdbc[Spring Data Examples] project.

A very good source of information is the source code in this repository.
Especially the integration tests (if you are reading this on GitHub, type `t` and then `IntegrationTests.java`)

We are keeping an eye on the https://stackoverflow.com/questions/tagged/spring-data-jdbc[spring-data-jdbc tag on Stack Overflow].

If you think you found a bug, or have a feature request, please https://github.com/spring-projects/spring-data-jdbc/issues[create a ticket in our issue tracker].

== Execute Tests

=== Fast running tests

Fast running tests can be executed with a simple

[source]
----
mvn test
----

This will execute unit tests and integration tests using an in-memory database.

=== Running tests with a real database

In order to run the integration tests against a specific database, you need to have a local Docker installation available, and then execute:

[source]
----
mvn verify -Dspring.profiles.active=<databasetype>
----

This will also execute the unit tests.

Currently, the following _databasetypes_ are available:

* hsql (default, does not require a running database)
* mysql
* mariadb
* postgres
* mariadb
* mssql
* oracle
* db2

Testing with Microsoft SQL Server and IBM DB2 requires you to accept the EULA of the respective Docker image so that the build may download and run it for you.
In order to accept the EULA, please add a file named `container-license-acceptance.txt` to the classpath, i.e. `src/test/resources` containing the name of the docker images.
At the time of this writing this would be

```
mcr.microsoft.com/mssql/server:2022-CU5-ubuntu-20.04
ibmcom/db2:11.5.7.0a
```

=== Run tests with all databases

[source]
----
mvn test -Pall-dbs
----

This will execute the unit tests and all the integration tests with all the databases we currently support for testing.