DATAJDBC-341 - Reworked the changes.

Turns out this was a little more involved than expected.
This modifies the implementation to not use exceptions for flow control.

Properties that get set via setter, wither or field access get not invoked for missing columns.
When properties get referenced in constructors a missing column results in an exception.

As a side effect we now access the `ResultSet` by index.
Depending on how the driver is implemented this might improve the performance a little.

Original pull request: #201.
This commit is contained in:
Jens Schauder
2020-03-17 13:53:09 +01:00
committed by Mark Paluch
parent c2062dbb9d
commit 95ca73df2f
11 changed files with 644 additions and 120 deletions

View File

@@ -440,6 +440,14 @@ public interface UserRepository extends CrudRepository<User, Long> {
----
====
For converting the query result into entities the same `RowMapper` is used by default as for the queries Spring Data JDBC generates itself.
The query you provide must match the format the `RowMapper` expects.
Columns for all properties that are used in the constructor of an entity must be provided.
Columns for properties that get set via setter, wither or field access are optional.
Properties that don't have a matching column will not get set.
The query is used for populating the aggregate root, embedded entities and one to one relationships including arrays of primitive types which get stored and loaded as SQL-array-types.
For maps, lists, sets and arrays of entities separate queries get generated.
NOTE: Spring fully supports Java 8s parameter name discovery based on the `-parameters` compiler flag. By using this flag in your build as an alternative to debug information, you can omit the `@Param` annotation for named parameters.
NOTE: Spring Data JDBC supports only named parameters.

View File

@@ -10,6 +10,7 @@ This section covers the significant changes for each version.
* Support for `PagingAndSortingRepository`.
* Full Support for H2.
* All SQL identifiers know get quoted by default.
* Missing column no longer cause exceptions as long as they are not required by the persitence constructor.
[[new-features.1-1-0]]
== What's New in Spring Data JDBC 1.1