Commit Graph

344 Commits

Author SHA1 Message Date
Jens Schauder
0609df0ae7 Reenable quoting for SqlServerDialect.
Quoting is important since it allows use of keywords as names.
We do not change the letter casing.
In a default setup the database does not care since it is case-insensitive.
If configured to be case-sensitive it makes sense to pass on what ever letter casing there is, since you seem to care.

Closes #1216
See #914
2022-08-31 15:48:54 +02:00
Jens Schauder
7b1f680a26 Correct behavior of NOOP deletes to match the specification in CrudRepository.
Delete operations that receive a version attribute throw an `OptimisticFailureException` when they delete zero rows.
Otherwise, the NOOP delete gets silently ignored.

Note that save operations that are determined to be an update because the aggregate is not new will still throw an `IncorrectUpdateSemanticsDataAccessException` if they fail to update any row.
This is somewhat asymmetric to the delete-behaviour.
But with a delete the intended result is achieved: the aggregate is gone from the database.
For save operations the intended result is not achieved, hence the exception.

Closes #1313
Original pull request: #1314.
See https://github.com/spring-projects/spring-data-commons/issues/2651
2022-08-31 15:30:24 +02:00
Jens Schauder
dad6e056e8 Avoid noop update for Id only aggregates.
Closes #1309
2022-08-25 14:19:04 +02:00
Jens Schauder
2a8f62245b Remove deprecated code.
This removes most currently deprecated code.

An exception are various deprecations in Spring Data R2DBC for which it is not obvious how to modify the code that is still using the deprecated API.

Original pull request #1304
2022-08-11 10:44:51 +02:00
Jens Schauder
07ade67862 Polishing.
Code formatting.

See #1073
Original pull request #1074
2022-08-10 14:03:14 +02:00
Jens Schauder
fd662bf9e6 Avoid duplicate selection of columns.
When the key column of a MappedCollection is also present in the contained entity that column got select twice.
We now check if the column already gets selected before adding it to the selection.

This only works properly if the column names derived for the entity property and the key column match exactly, which might require use of a `@Column` annotation depending on the used NamingStrategy.

Closes #1073
Original pull request #1074
2022-08-10 14:02:51 +02:00
Mark Paluch
0d1ba211c5 Polishing.
Reuse H2 dialect settings in R2DBC-specific H2 dialect.
Refactor ArrayColumns support classes, into toplevel-types. Let R2DBC H2 sublass the relational H2Dialect to decouple from Postgres.

See #1287
Original pull request #1297
2022-08-10 13:01:02 +02:00
Mark Paluch
d79ba7911f Allow disabling entity lifecycle events.
We now support disabling lifecycle events through the Template API to reduce the framework overhead when events are not needed.

Closes #1291
2022-07-21 09:49:42 +02:00
Jens Schauder
6958157a7e Use TypeScanner instead of ClassPathScanningCandidateComponentProvider.
Closes #1288
2022-07-13 16:02:04 +02:00
Mark Paluch
df9cecbdcf Polishing.
Adopt to improved naming scheme for runtime hints.

See #1269
2022-07-13 15:03:41 +02:00
Jens Schauder
aad40a32b0 Polishing.
Added `@since` comments for new methods and classes.
General formatting and code style tweaking.
Github references for new tests added.
Fixes for integration tests with various databases:
- Not all stores support submillisecond precision for Instant.
- Count for exists query doesn't work for all databases, nor does `LEAST(COUNT(1), 1)`
- MariaDB defaults timestamp columns to the current time.
- Ordering was applied twice.
- DATETIME in SqlServer has a most peculiar preceision. We switch to DATETIME2.

Original pull request #1195
See #1192
2022-07-13 12:55:06 +02:00
Jens Schauder
86f0140f79 Moved QueryMapper.
The use of QueryMapper caused dependency cycles.

Original pull request #1195
See #1192
2022-07-13 12:54:42 +02:00
Diego Krupitza
a6fb4df590 Support for Query By Example.
Original pull request #1195
Closes #1192
2022-07-13 12:54:07 +02:00
Christoph Strobl
1467d63f61 Simplify auditing setup
Use IsNewAwareAuditingHandler factory method to avoid exposing additional beans.

See: #1279
2022-07-08 11:21:37 +02:00
Mark Paluch
b71e3b9697 Polishing.
Refine name and visibility of runtime hints registrars.

See #1279
see #1269
2022-07-07 09:01:39 +02:00
Mark Paluch
58bb158004 Add support for RelationalManagedTypes.
See #1269
2022-07-06 15:27:40 +02:00
Christoph Strobl
6943cfa659 Add AOT jdbc repository support.
We now use the AOT infrastructure of Spring Framework 6 and data commons to provide AOT support building the foundation for native image compilation.
Additionally we register hints for GraalVM native image.
Update auditing configuration to avoid inner bean definitions.

See: #1269
2022-07-05 12:32:19 +02:00
Jens Schauder
dd663384ac Upgrade MS SQL Server Docker image version to 2019-CU16-ubuntu-20.04
Closes #1283
2022-07-04 15:13:32 +02:00
Jens Schauder
09c3088a78 Upgrade MariaDb Docker image to 10.8.3
Closes #1282
2022-07-04 12:37:46 +02:00
Jens Schauder
fbd44bd349 Upgrade DB2 Docker image to 11.5.7.0a.
Closes #1272
2022-06-23 16:25:36 +02:00
Jens Schauder
a271c43c83 Upgrade MySql Docker image to version 8.0.29.
Closes #1271
2022-06-23 14:53:40 +02:00
Jens Schauder
a263d992b7 Upgrade Oracle Docker image to version 21.3.0-slim
Closes #1268
2022-06-21 12:56:49 +02:00
Jens Schauder
0b686ef3a7 Upgrade PostgreSql Docker image to version 14.3
Closes #1267
2022-06-21 11:27:53 +02:00
Jens Schauder
ed7853d2d0 Polishing.
Original pull request #1231
See #537
2022-06-20 15:07:54 +02:00
Chirag Tailor
1a283fa406 Add DeleteBatchingAggregateChange to batch DeleteRoot actions.
Original pull request #1231
See #537
2022-06-20 15:06:46 +02:00
John Blum
483b30e8c2 Remove punctuation in Exception messages.
Closes #1259.
2022-06-08 12:16:37 -07:00
Jens Schauder
6911bfba98 Polishing.
Introduces the BatchedActions abstraction to encapsulate the different ways singular actions get combined into batched actions.

Original pull request #1230
Original pull request #1229
Original pull request #1228
Original pull request #1211
2022-06-08 14:54:19 +02:00
Chirag Tailor
64a07e608d Add DeleteBatchingAggregateChange to batch deletes when deleting multiple aggregate roots.
+ Rename DefaultAggregateChange to DeleteAggregateChange.

Original pull request #1230
2022-06-08 14:54:19 +02:00
Jens Schauder
cf6e174088 Polishing.
Original pull request #1229
2022-06-08 14:54:18 +02:00
Chirag Tailor
aa1610d381 Update SaveBatchingAggregateChange to batch Delete actions.
Original pull request #1229
2022-06-08 14:53:51 +02:00
Chirag Tailor
ec3cec3be3 Update SaveBatchingAggregateChange to batch InsertRoot actions.
Original pull request #1228
2022-06-08 14:53:30 +02:00
Jens Schauder
c1164383d6 Polishing.
Original pull request #1211
2022-06-08 14:53:30 +02:00
Chirag Tailor
6b02a4e627 Add SaveMergedAggregateChange which merges AggregateChangeWithRoot changes into one.
Remove behavior from WritingContext for creating InsertBatch in favor of SaveMergedAggregateChange.

Update all save paths to use SaveMergedAggregateChange.

+ Update #populateIdsIfNecessary return type from T to List<T>

Pull out an abstract BatchWithValue class from InsertBatch to use it for batching root inserts as well.

Rename InsertBatch to BatchInsert
Rename AggregateChangeWithRoot to RootAggregateChange.

Original pull request #1211
2022-06-08 14:48:51 +02:00
Jens Schauder
63b0f5a01a Polishing.
See #1254
2022-06-01 12:46:20 +02:00
Jens Schauder
a5238fac85 Reestablish previous exception behavior.
When saving an Aggregate which is not new, but has a null version attribute we now throw a DbActionExecutionException, like we used to.

Closes #1254
2022-06-01 12:46:20 +02:00
Jens Schauder
dcd4ef0cdc Support readonly properties for references.
The `@ReadOnlyProperty` annotation is now honoured for references to entities or collections of entities.

For tables mapped to such annotated references, no insert, delete or update statements will be created.
The user has to maintain that data through some other means.
These could be triggers or external process or `ON DELETE CASCADE` configuration in the database schema.

Closes #1249
Original pull request #1250
2022-05-23 10:42:31 +02:00
Jens Schauder
274fcd7e87 Polishing.
Original pull request #1226
See #1212
2022-05-17 14:43:58 +02:00
Chirag Tailor
64a7c5595a Update @Query argument conversion to handle Collection<Enum>.
+ Copy logic from QueryMapper#convertToJdbcValue to resolve Iterable
  arguments on findBy* query methods to resolve the same for @Query.
+ Use parameter ResolvableType instead of Class to retain generics info.

Original pull request #1226
Closes #1212
2022-05-17 14:43:04 +02:00
Jens Schauder
e6ff3859ed Drop support for H2 1.x.
Closes #1243
2022-05-16 14:00:09 +02:00
Jens Schauder
f6d31eeb4c Downgrade to mybatis-spring 2.0.7.
Since at the time of the release only snapshot releases of mybatis-spring 2.1 are available we decided to downgrade to 2.0.7. for the release.

Unfortunately that release is not compatible with the current milestone of Spring Framework and therefore the MyBatis integration is broken.

If you want to use MyBatis with this release, manually add a dependency to mybatis-spring 2.1.0-SNAPSHOT.

Closes #1245
2022-05-13 09:14:44 +02:00
Jens Schauder
4353dc8e06 Improve and clarify documentation of callbacks.
This also removes deprecated Events and Callbacks.

Closes #1236
2022-05-11 15:45:03 +02:00
Jens Schauder
f2dc64ec52 Polishing.
Formatting and comments.

See #1201
See #1199
Original pull request #1208
2022-03-29 10:10:11 +02:00
Chirag Tailor
508791b7df Capture execution results for update db actions to fix root references with immutably typed ids.
+ Added #getIdValueSource to DbAction.WithEntity since it now applies to all such DbAction.
+ Removed DbAction.WithGeneratedId in favor of DbAction.WithEntity where it was used.

Removes unused DbAction.Update.

Passes the root from BeforeSaveCallback through to InsertRoot,UpdateRoot
actions.

+ Isolate aggregate change #getEntity #setEntity behaviors into a new
interface for "save" changes.
+ Extract #setEntity from DbAction.WithEntity to a new DbAction interface
just for root actions.
+ JdbcAggregateChangeExecutionContext#populateIdsIfNecessary returns the root entity
from DbAction.InsertRoot or DbAction.UpdateRoot regardless of the immutability of
its @Id property.

Closes #1199
Closes #1201
Original pull request #1208
2022-03-29 10:07:54 +02:00
Jens Schauder
657e9cac65 Polishing.
Changed default behaviour to an empty name for embedded entities.
This allows to use embedded entities for column tuples without special prefix.

Original pull request #1149
2022-03-23 15:31:59 +01:00
Daniil Razorenov
b53e4e6091 Fix assemble table alias for embedded entity with empty prefix and reference.
Table alias for embedded entity use prefix value from Embedded annotation. But default value for prefix is empty string. If try to create SqlIdentifier for empty string it throw exception. To avoid this behavior, if prefix is an empty string, property name for embedded entity is taken instead.
2022-03-23 15:31:59 +01:00
Jens Schauder
a4d2f1ef05 Polishing.
This change extracts entity modifying behaviour into separate methods, so it doesn't appear as an unexpected side effect of the creation of aggregate changes.

Also some formatting.

Original pull request #1196
See #1137
2022-03-22 17:10:41 +01:00
Chirag Tailor
6500bfed3a Determine and set the value for entity @Version before conversion to DbActions to simplify execution context.
This change incorporates one test from https://github.com/spring-projects/spring-data-relational/pull/1150

Original pull request #1196
Closes #1137
2022-03-22 17:10:41 +01:00
Mark Paluch
32ec464572 Disable package cycle tests.
Property Converters introduced a cycle so we're disabling the tests for now as we cannot resolve these from here.

See #1132
2022-03-21 08:47:36 +01:00
Jens Schauder
e019b3695a Polishing.
Formatting.

See #1159
Original pull request # 1191
2022-03-16 14:28:01 +01:00
Chirag Tailor
226bb71708 Batch inserts of referenced entities.
Insert for entities of same type within an aggregate get inserted using JDBC batch operations when possible.

Inserts are supported when no id needs to be generated by the database or if the Dialect supports generation of ids in batch operations.

Closes #1159
Original pull request # 1191
2022-03-16 14:27:44 +01:00