Commit Graph

243 Commits

Author SHA1 Message Date
Mark Paluch
02ba403d07 Fix dynamic query method projection.
Query methods returning dynamic projections based on a Class argument now properly apply projection conversion. Previously, classes not seen by the mapping context were skipped and that caused projecting query methods to return the actual entity type.

Closes #607
2021-06-22 11:22:12 +02:00
Mark Paluch
b8709a6824 Polishing.
Rename method to renderForGeneratedValues to reflect its intended usage and enhance documentation.

Tweak Javadoc.

Closes: #483
Original pull request: #602.
2021-06-11 08:37:29 +02:00
Jens Schauder
1119833c54 Registration of columns for generated keys is now dialect dependent.
Different R2DBC drivers expect generated keys when they are in camel case to be quoted or unquoted.
This can now be controlled by implementing `Dialect.renderForGeneratedKeys`.

Closes: #483
Original pull request: #602.
2021-06-11 08:27:48 +02:00
Mark Paluch
c8122a9b41 Refine conversion directions between boolean and byte using MySQL/MariaDB.
ByteToBooleanConverter is now marked as reading converter and we've added a writing converter with BooleanToByteConverter to ensure proper conversion. Previously, all byte values were converted to boolean resulting in data precision loss.

Closes #589
2021-05-19 10:37:47 +02:00
Mark Paluch
78eba8611d Polishing.
Introduce assertions for OutboundRow.

Closes #593
2021-05-04 08:53:19 +02:00
Mark Paluch
2e116df224 Correctly translate absent convertible enum values to String[] using Postgres.
We now correctly obtain the target type for a persistent property that should be converted into an array value prior to constructing Parameter.
Previously, we fell back to the actual type without considering potential converters which left collection-like enum properties without a value with the enum array type that was potentially not supported by the database driver.

Closes #593
2021-05-04 08:53:12 +02:00
Mark Paluch
3513c45b4b Upgrade to MySQL 8.0.
Switch to a newer MySQL version to use TLSv1.2 as newer JRE versions no longer support TLSv1/TLSv1.1.

Closes #594.
2021-05-03 15:03:09 +02:00
Mark Paluch
5363184c1a Remove Jasync from tests.
Jasync does not support MySQL's 8.0 caching_sha2_password and there are no plans to support it.

See #594.
2021-05-03 14:57:15 +02:00
Mark Paluch
c6da8dae04 Polishing.
Add unit test.

See #587.
2021-04-22 11:48:40 +02:00
Mark Paluch
ae2704876b Eagerly check for custom converters when reading rows.
We now eagerly check for the presence of custom converters, before attempting to materialize a nested entity when reading a Row.

Closes #585
2021-04-21 09:21:13 +02:00
Mark Paluch
6175297bff Polishing.
Reformat integration test.

See #573
Original pull request: #574.
2021-04-06 13:00:28 +02:00
AbstractCoder
ea2b1f2e25 Add Interval to Postgres simple types.
io.r2dbc.postgresql.codec.Interval is now considered a simple type.

Closes #573
Original pull request: #574.
2021-04-06 13:00:28 +02:00
Mark Paluch
690c693c9c Polishing.
See #557
2021-03-17 09:05:03 +01:00
Mark Paluch
5a024fb3fe Move default Id value cleanup on insert from Converter into R2dbcEntityTemplate.
We now check in R2dbcEntityTemplate whether we need to skip the Id value if its value is null or a primitive using its default. Previously, the check was located in the converter. Converting an entity afteri ncrementing the version of a versioned entity would write the Id value as the entity was no longer considered to be new.

Closes #557.
2021-03-17 09:05:02 +01:00
Mark Paluch
fab6d76721 Polishing.
Make count assertions case-insensitive regarding the count column name. Add missing license headers. Support DatabaseContainer without a database name.

See #230
2021-03-15 10:20:38 +01:00
Mark Paluch
8f97d37558 Add support for Oracle's R2DBC driver.
We support Oracle's experimental R2DBC driver by providing a dialect including bind markers. Since the driver is not yet available from Maven Central and it requires module-path support for ServiceLoader discovery, we need to apply a few workarounds including absence check for our integration tests.

See #230
2021-03-15 10:20:38 +01:00
Mark Paluch
d725b4c9ba Use SqlIdentifier.getReference() when calling Row.get(…).
We now use the referencename instead of toString() when obtaining values from Row.

Closes #530.
2021-02-01 16:24:50 +01:00
Mark Paluch
7375273e70 Polishing.
Reduce method visibility.

See #519
2021-01-08 11:04:33 +01:00
Mark Paluch
c745165366 Read domain type when returning an implemented interface from repository query methods.
We now read the domain type instead of trying to materialize an interface if the type returned from the query method is implemented by the domain object handled by the repository.

Closes #519
2021-01-08 11:04:33 +01:00
Mark Paluch
cecad1c9cf Polishing.
Reduce test method/class visibility.

See #518
2021-01-07 15:39:07 +01:00
Mark Paluch
2b900a913b Apply UPPER function to all columns when enabling ignoreCase.
We now apply the UPPER function regardless of whether we could resolve the criteria property to a column. Previously, we required a resolved property of a String type which prevented non-mapped properties from case-insensitive queries.

Closes #518
2021-01-07 15:39:07 +01:00
Mark Paluch
b28a24e003 Update copyright year to 2021.
Closes #523
2021-01-07 11:39:36 +01:00
Mark Paluch
6d63b5ea93 #492 - Polishing.
Use Java 8 syntax for Map creation. Add author tags. Use simpler table names.

Original pull request: #493.
2020-11-10 12:12:27 +01:00
JoseLion
d80b8d502d #493 - Add HStore support on Postgres dialect.
Original pull request: #493.
2020-11-10 12:12:27 +01:00
Mark Paluch
b8f4e8b765 #475 - Refine projection result mapping.
We now differentiate the result mapping based on projection type and query type. Previously, all projections used the domain type to map results first and then serve as backend for the projection proxy/DTO creation.
We now use direct result to DTO mapping for String-based queries to allow for a greater flexibility when declaring DTO result types. Interface-based projections and derived queries remain using the two-step process of result to domain type mapping and then mapping the domain type into the projection.
2020-10-08 15:04:14 +02:00
Mark Paluch
03a667ca6d #465 - Convert bind values for String-based queries to their native type.
We now invoke the converter for query arguments of String-based queries (using the Query annotation or named queries) to convert the value into a type that can be used by the driver.

Previously all values were passed-thru which caused for e.g. enums to pass-thru these to the driver and the driver encode failed.
2020-10-07 14:50:54 +02:00
Mark Paluch
c3cb70f5ec #469 - Suppress emission of null values when using simple and primitive result types.
Results projected onto simple and primitive types that are null are no longer emitted.

A SQL query SELECT MAX(age) FROM my_table that returns a SQL NULL and that would be consumed as Long.class (Publisher<Long>) is an example for a primitive type that can be null. Since Reactive Streams prohibits the propagation of null values by a Publisher to a Subscriber the only viable option is to suppress null results by wrapping the mapping function into Optional result values and filter these values later to avoid null being emitted.
2020-10-02 10:47:32 +02:00
Mark Paluch
7a094b6765 #395 - Add support for suspend repository query methods returning List<T>. 2020-09-22 14:53:58 +02:00
Mark Paluch
d3823947aa #468 - Correctly map result of exists queries.
We now map results of exists queries to a boolean flag to ensure proper decoding. Previously, results were attempted to be mapped onto a primitive type which failed as there's no converter registered for Row to Boolean.
2020-09-21 15:17:45 +02:00
Mark Paluch
f0b30f0ca0 #467 - Migrate tests to JUnit 5.
Migrate also ExternalDatabase from JUnit rule to BeforeAllCallback and RegisterExtension.
2020-09-21 14:42:05 +02:00
Mark Paluch
68c2304b73 #413 - Disable test used as documentation include. 2020-09-18 09:20:42 +02:00
Mark Paluch
c23485d90e #413 - Introduce constructor to R2dbcEntityTemplate accepting ConnectionFactory.
This is a short-cut constructor that allows for simpler creation of the Template API.
2020-09-17 17:52:18 +02:00
Mark Paluch
ce57b25cd0 #413 - Refine reference documentation after Spring R2DBC migration. 2020-09-17 11:14:01 +02:00
Mark Paluch
4506fb67ca #453 - Introduce converters to consume Postgres Json and convert these to String/byte[].
We now ship converters for Postgres' Json data type to map JSON to String and to byte[] for easier and safe consumption.
2020-09-10 09:21:15 +02:00
Mark Paluch
b720249dac #454 - Adapt to changed array assertions in AssertJ. 2020-09-09 15:51:54 +02:00
Mark Paluch
0868f2aaef #423 - Add r2dbc-postgresql Geotypes to simple types.
R2DBC Postgres Geo-types are now considered simple types that are passed-thru to the driver without further mapping. Types such as io.r2dbc.postgresql.codec.Circle or io.r2dbc.postgresql.codec.Box can be used directly in domain models and as bind parameters.
2020-09-09 11:40:04 +02:00
Mark Paluch
7d3bd1f30a #444 - Initialize primitive Id properties upon INSERT.
We now propagate auto-generated Id values to primitive Id properties if the value in the domain model is zero. This happens in addition to non-primitive values being null to ensure that generated values end up in the domain model.
2020-09-09 11:22:48 +02:00
Mark Paluch
43d5d9d827 #451 - Initialize version for versioned entities after BeforeConvert callback.
We now initialize/increment the version of versioned entities (optimistic locking) after running the BeforeConvert callback. BeforeConvert callbacks may contain features such as auditing and if the auditing callback issues a isNew check, then the version would be already populated which leads to the auditing callback considering the entity not new anymore leaving the created date empty.
2020-09-09 09:25:21 +02:00
Mark Paluch
d7a76609b2 #450 - Add support for @Value when constructing entities using their persistence constructor.
We now support the use of @Value in persistence constructors to compute values for constructor creation.

class MyDomainObject {

	public MyDomainObject(long id, @Value("#root.my_column") String my_column, @Value("5+2") int computed) {
		// …
	}
}
2020-09-08 10:43:30 +02:00
Mark Paluch
a1081bbbb2 #447 - Deprecate ReactiveDataAccessStrategy.
ReactiveDataAccessStrategy is now deprecated in favor of using StatementMapper, UpdateMapper, and R2dbcConverter directly. The access strategy interface was introduced to allow pluggable access strategies in DatabaseClient. With moving DatabaseClient into Spring Framework, this approach is no longer required.
2020-09-08 09:58:07 +02:00
Mark Paluch
b4002e5c3f #440 - Create R2dbcEntityTemplate in R2dbcRepositoryFactoryBean.
We now create R2dbcEntityTemplate as part of R2dbcRepositoryFactoryBean initialization if the factory bean was configured with DatabaseClient and DataAccessStrategy only. Creating the template in the factory bean allows collecting entity callbacks for repository usage.
2020-09-03 11:07:34 +02:00
Mark Paluch
7bf9ea7156 #411 - Introduce EnumWriteSupport for simpler pass-thru of enum values.
We now provide EnumWriteSupport as base class for enum write converters that should be written as-is to the driver.

R2dbcCustomConversions can now also be created from a dialect for easier R2dbcCustomConversions creation.
2020-08-06 10:59:42 +02:00
Mark Paluch
67c3d492a2 #402 - Exclude id property using initial value when inserting objects.
We now exclude Id properties from being used in the INSERT field list if the Id value is zero and of a primitive type or if the value is null using a numeric wrapper type.
2020-08-05 14:19:50 +02:00
Mark Paluch
ecbb8d8e78 #414 - Adopt SpEL support to use ReactiveEvaluationContextProvider.
We now defer query creation to obtain and resolve SpEL expression dependencies using reactive SpEL context extensions.
2020-08-05 12:17:35 +02:00
Mark Paluch
3d59c63bc0 #368 - Polishing.
Original pull request: #412.
2020-08-04 14:53:19 +02:00
Mark Paluch
086c5a1d2d #368 - Use Spring R2DBC.
We now use Spring R2DBC DatabaseClient and utilities to implement Spring Data R2DBC functionality.

Original pull request: #412.
2020-08-04 14:53:16 +02:00
Mark Paluch
f331572167 #368 - Deprecate API provided by Spring R2DBC.
This commit deprecates API that has been moved to Spring R2DBC.

Original pull request: #412.
2020-08-04 14:53:09 +02:00
Mark Paluch
2f9ca57ed5 #421 - Polishing.
Simplify tests. Use ReflectionUtils.isVoid(…) where possible and simplify isVoid(…) flows.

Original pull request: #422.
2020-07-31 11:40:01 +02:00
Stephen Cohen
748d6c3340 #421 - Handle modifying query methods returning kotlin.Unit.
Added check for kotlin.Unit to AbstractR2dbcQuery#getExecutionToWrap. This case is essentially equivalent to a return type of Void, but the singleton Unit instance needs to be returned instead of discarding the result entirely.

It was also necessary to add a check to R2dbcQueryMethod#getEntityInformation, as otherwise a PersistentEntity is created for Unit, which leads to a new instance being created via reflection down the pipeline (which is probably not a thing that should happen).

Original pull request: #422.
2020-07-31 11:39:50 +02:00
Mark Paluch
4f04c87837 #421 - Suppress results for suspended query methods returning kotlin.Unit.
We now discard results for suspended query methods if the return type is kotlin.Unit.

Related ticket: DATACMNS-1779

Original pull request: #422.
2020-07-31 11:39:45 +02:00