Commit Graph

157 Commits

Author SHA1 Message Date
Jens Schauder
4bf2b8d0a8 DATAJDBC-257 - Adds DB2 support.
Db2Dialect added in order to support DB2.
Added test configuration files.
Adapted some tests to make them properly work with DB2
QueryAnnotationIntegrationTests converted into an Hsqldb only test since it is next to impossible to make it work across databases since it heavily depends on database and driver specifics.

Removed license acceptance file from the repository in order to not accept a license in the name of someone forking the repository.
For the CI build an appropriate file gets created on the fly.

Original pull request: #213.
2020-05-06 15:49:07 +02:00
Mark Paluch
b0d37bda8a DATAJDBC-529 - Polishing.
Rearrange imports.

Original pull request: #212.
2020-05-05 13:48:53 +02:00
Jens Schauder
370ee4464e DATAJDBC-529 - Use specialized ResultSetExtractor for exists queries.
Exists queries do not look at the value returned in the ResultSet but just check if there is a row.

Original pull request: #212.
2020-05-05 13:45:19 +02:00
Jens Schauder
ac88f1d4f9 DATAJDBC-530 - Polishing.
Original pull request: #210.
2020-05-04 09:19:35 +02:00
mhyeon-lee
f9bc40cc46 DATAJDBC-530 - The sorting property set as the property name.
Original pull request: #210.
2020-05-04 09:17:18 +02:00
Jens Schauder
6420205eed DATAJDBC-524 - Fixed dependency cycles triggered by DATAJDBC-318.
Moved Identifier and IdentifierBuilder to ...jdbc.core.convert.
Moved RelationaAuditingCallback to ..mapping.event.

Improved DependencyTests to properly consider "relational" a main module.
2020-04-28 11:09:52 +02:00
Jens Schauder
d80614b4d8 DATAJDBC-318 - Fixed the generation of the select list.
The select list must include columns for 1:1 relationships.

The implementation is copied from SqlGenerator and will be unified in the near future.

Original pull request: #209.
2020-04-28 09:23:52 +02:00
Mark Paluch
aadbb667ed DATAJDBC-318 - Extend query method validation.
We now reject criteria predicates for collections, maps and references. The select list selects all columns until DATAJDBC-523 is solved.

Original pull request: #209.
2020-04-28 09:23:52 +02:00
Jens Schauder
fd98e16038 DATAJDBC-318 - Adding a failing test.
Added failing tests for entities with references.

Code deduplication.
Documentation wording.
Formatting.

Original pull request: #209.
2020-04-28 09:23:52 +02:00
Mark Paluch
999bf29321 DATAJDBC-318 - Initial support for query derivation.
Move JdbcRepositoryQuery into repository.query package. Split JdbcRepositoryQuery into AbstractJdbcQuery and StringBasedJdbcQuery.
Add QueryMapper for mapping of Criteria.
Initial support for query derivation.

Emit events and issue entity callbacks only for default RowMapper.
Custom RowMapper/ResultSetExtractor are in full control of the mapping and can issue events/callbacks themselves.

Update reference documentation.

Original pull request: #209.
2020-04-28 09:23:52 +02:00
Jens Schauder
2f3f00bd71 DATAJDBC-318 - Adapting DependencyTests.
Without this change we see cyclic dependencies between modules (i.e. subpackages).
The following subpackages had a cycle:

repository.query and repository.query.parser

PartTreeJdbcQuery and JdbcQueryCreator(repository.query from jdbc) depend on PartTree (repository.query.parser)

AbstractQueryCreator (repository.query.parser) depends on ParameterAccessor (repository.query from commons)

This change changes the definition of a module, bundling all the modules above into one module (repository).

Alternative changes that should fix the problem:
1. Move ParameterAccessor to a different (probably new package)
2. Move AbstractQueryCreator to a different (probably new package)
3. org.springframework.data.jdbc.repository.query to e.g. org.springframework.data.jdbc.repository.query.jdbc

Original pull request: #209.
2020-04-28 09:23:52 +02:00
Jens Schauder
c8cbdc5ea0 DATAJDBC-507 - Polishing.
Reduced code duplication.
Fixed Lombok related warnings.

Original pull request: #208.
2020-04-20 12:42:40 +02:00
tirbison
d7fe83c256 DATAJDBC-507 - Optimistic locking version for non primitives start with 0.
This makes the behaviour consistent with that of other Spring Data modules.

Original pull request: #208.
2020-04-20 12:42:40 +02:00
Jens Schauder
2b6f7b2b48 DATAJDBC-480 - Removed various deprecated symbols.
Removal of public API that was deprecated in version 1.1 or older.

Original pull request: #204.
2020-04-01 13:57:21 +02:00
Mark Paluch
c0803ddafe DATAJDBC-341 - Polishing.
Remove SpecialColumnValue in favor of JdbcPropertyValueProvider.hasProperty(…). Rename ResultSetWrapper to ResultSetAccessor. Replace ResultSetAccessor usage in JdbcConverter with ResultSet to avoid visibility issues.

Original pull request: #201.
2020-03-31 11:46:58 +02:00
Jens Schauder
95ca73df2f 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.
2020-03-31 11:46:43 +02:00
Thomas Lang
c2062dbb9d DATAJDBC-341 - Map NULL values in EntityRowMapper for columns not being fetched in the query.
Original pull request: #170.
2020-03-30 19:55:41 +02:00
Mark Paluch
6769528068 DATAJDBC-453 - Polishing.
Remove unused AggregateChangeExecutionContext. Extract MutableAggregateChange interface and use it to encapsulate the implementation class. Expose MutableAggregateChange in entity callbacks where mutation of the MutableAggregateChange is intended.

Fix generics and license headers, tweak Javadoc.

Original pull request: #197.
2020-03-30 14:08:15 +02:00
Jens Schauder
51b6784579 DATAJDBC-453 - DbActions and AggregateChange are effectively immutable.
Removed the Interpreter and replaced it with AggregateChangeExecutor and  AggregateChangeExecutionContext.
The latter handles the mutable data like ids and versions.

Original pull request: #197.
2020-03-30 14:08:03 +02:00
Mark Paluch
d61651ad1e DATAJDBC-514 - Polishing.
Use AssertJ version specified by Spring Data Build.

Original pull request: spring-projects/spring-data-r2dbc#295.
2020-03-27 16:12:05 +01:00
Jens Schauder
beaeb5cbdf DATAJDBC-512 - Polishing.
Removed some accidental leftovers from the development process.
Added a note in the `new-features`.

Original pull request: #203.
2020-03-26 17:22:44 +01:00
Mark Paluch
4e23fa6fdf DATAJDBC-512 - Add support H2 dialect.
Original pull request: #203.
2020-03-26 17:22:44 +01:00
Mark Paluch
ef02b6e9cd DATAJDBC-455 - Polishing.
Rename Dialect bean to jdbcDialect to avoid generic bean names. Require JdbcOperations in DialectResolver. Rename JdbcDialectResolver to DialectResolver for consistent naming with R2DBC the underlying type is a Dialect.

Tweak Javadoc and extend documentation with custom conversions include from Spring Data Commons. Extract MySQL identifier processing defaults into constant.

Original pull request: #202.
2020-03-26 11:08:55 +01:00
Jens Schauder
956ad24d4f DATAJDBC-487 - Makes the IdentifierProcessing for MySqlDialect dynamic.
This allows to handle the various ways MySQL may behave, depending on the OS it is installed on and on its configuration.

Original pull request: #202.
2020-03-26 11:08:49 +01:00
Jens Schauder
4c3fa05b6c DATAJDBC-455 - Adds dynamic Dialect detection.
So far the user had to specify an `Dialect` themselves if they wanted to use anything but HSQLDB.
We now identify the supported databases and pick the appropriate `Dialect`.

Vendors who want to offer support for their database may provide an implementation of `JdbcDialectProvider` and register it using a  file under the key `org.springframework.data.jdbc.repository.config.DialectResolver$JdbcDialectProvider`.

Original pull request: #202.
2020-03-26 11:08:14 +01:00
Jens Schauder
36192c4d97 DATAJDBC-510 - Polishing.
Minor formatting and removal of a deprecated constructor since this is for a major release anyway.

Original pull request: #192.
2020-03-25 13:49:39 +01:00
mhyeon-lee
54fed8ac5f DATAJDBC-510 - Inject IdentifierProcessing into BasicJdbcConverter.
Before the `IdentifierProcessing` was hardcoded and therefore did not match a properly configured `Dialect`.

Original pull request: #192.
2020-03-25 13:49:27 +01:00
Jens Schauder
5fdfd3a9dc DATAJDBC-454 - Adds generics to events.
Events now have a type parameter for the type of aggregate root they relate to.
In order to utilize this an react to only events relating to a specific type of entity `AbstractRelationalEventListener` was added.

Original pull request: #199.
2020-03-19 09:21:56 +01:00
Jens Schauder
22f9eded60 DATAJDBC-454 - Redesigned events.
Ids are only contained if it can not be guaranteed that an entity is contained which applies to the delete events.
As a side effect Identifier got simplified into a single simple class.

Original pull request: #199.
2020-03-19 09:21:41 +01:00
Michal Fotyga
7a2a3fb2eb DATAJDBC-506 - Fix some typos in code and documentation.
Original pull request: #200.
2020-03-16 08:56:01 +01:00
Mark Paluch
0ba523c780 DATAJDBC-503 - Adapt to Mockito 3.3 changes.
Mockito reports falsely unnecessary stubbings so we're switching to the silent runner for these cases.
2020-03-11 09:00:20 +01:00
Mark Paluch
188b9d4388 DATAJDBC-491 - Correctly combine schema- and table name.
We no correctly combine schema and table name using separate SqlIdentifier objects instead of leaving the schema name as part of the table name. Previously, the concatenated name failed to resolve with quoted identifiers.
2020-02-21 14:43:09 +01:00
Jens Schauder
c907eb1d35 DATAJDBC-488 - Polishing.
JdbcRepositoryConcurrencyIntegrationTests now only runs with MySql instead of always with MySql.
Also modified it to not use sleep.
Copyright header added.
Formatting.

Original pull request: #191.
2020-02-21 13:16:15 +01:00
mhyeon-lee
06529abf5a DATAJDBC-488 - Avoid deadlocks by first accessing the root entity.
The previous process of deleting referencing entities, updating the root and then inserting referencing entities hat the potential of causing deadlocks.
When one process didn't obtain a lock on delete because there wasn't anything to delete root and referencing entities got locks in opposite order, which is a classical cause for deadlocks.

Original pull request: #191.
2020-02-21 13:15:46 +01:00
Mark Paluch
95428b7022 DATAJDBC-492 - Use JdbcMappingContext in AbstractJdbcConfiguration instead of RelationalMappingContext.
We use now a more concrete type in the configuration to avoid clashes when Spring Data R2DBC is on the class path.
2020-02-20 10:20:46 +01:00
Jens Schauder
91ddda0c3f DATAJDBC-479 - Polishing.
Fixes compiler error from rebase rebase.
Removes IdentifierProcessingAdapter since it wasn't used anymore
Merged UnquotedDialect with NonQuotingDialect since both served the same purpose of a simple Dialect for testing.
Formatting.

Original pull request: #187.
2020-02-11 20:28:05 +01:00
Mark Paluch
592f483699 DATAJDBC-479 - Use SqlIdentifier in SQL AST.
We now use SqlIdentifier to encapsulate names and aliases of tables, columns and functions.

We now use proper delegation to ConditionVisitor to render a JOIN condition.
Previously, we used toString() of Condition segments which rendered an approximation of the condition.
ConditionVisitor applies RenderContext settings that consider identifier quoting and normalization strategies.

Original pull request: #187.
2020-02-11 20:26:57 +01:00
Jens Schauder
595559bf28 DATAJDBC-484 - Fixes a JDK dependent test failure.
Beginning from JDK 10 `Instant` uses nanosecond precision which doesn't make it through the database.
This caused the test to fail.
This fix fixes only the test by making the assertion more lenient.
Actually storing and retrieving nanosecond precision time values is a separate issue.

Also reduced logging in tests again.
2020-02-07 15:35:52 +01:00
Jens Schauder
4a8888e296 DATAJDBC-101 - Polishing.
Refactored SQL generation.
Adapted some assertions to the "Spring Data JDBC style".
Minor formatting.

Original pull request: #188.
2020-02-07 10:29:11 +01:00
Milan Milanov
7f578ed2bb DATAJDBC-101 - Adds support for paging and sorting repositories.
Original pull request: #188.
2020-02-07 10:28:58 +01:00
Mark Paluch
f1d2d78dc8 DATAJDBC-464 - No longer require MappingContext to create BasicRelationalPersistentProperty.
We now no longer require MappingContext to create BasicRelationalPersistentProperty and BasicJdbcPersistentProperty.
We require only the NamingStrategy so we're just passing that one instead of the entire context.

Original pull request: #186.
2020-01-31 13:17:51 +01:00
Mark Paluch
b29a789846 DATAJDBC-464 - Move RelationalPersistentProperty.getColumnType() and getSqlType() to JdbcConverter.
RelationalPersistentProperty.getColumnType() and getSqlType() are no longer members of RelationalPersistentProperty but part of the JdbcConverter. Both methods have a strong affinity to JDBC-specifics and belong rather into the conversion strategy and not into mapping-metadata.

Original pull request: #186.
2020-01-31 13:17:49 +01:00
Mark Paluch
8de5683b71 DATAJDBC-464 - Polishing.
Fix generics. Reformat code. Improve method names.

Original pull request: #186.
2020-01-31 13:17:47 +01:00
Jens Schauder
5ed80dfdb6 DATAJDBC-464 - Convert parameters.
Parameters now get converted to a suitable type supported by JDBC.

In order to support this the logic of finding the "right" type got moved from `BasicRelationalPersistentProperty` to `JdbcCompatibleTypes`.

Original pull request: #186.
2020-01-31 13:17:37 +01:00
Jens Schauder
d77e9cd837 DATAJDBC-481 - Properly increase version of immutable aggregate roots on update. 2020-01-30 10:12:11 +01:00
Jens Schauder
2f9d4b2c83 DATAJDBC-481 - Improved test for optimistic locking version increase. 2020-01-30 10:12:11 +01:00
Jens Schauder
36b419e712 DATAJDBC-386 - Polishing.
Tests that used the `@Column` annotation to map multiple properties to a single database column failed.
Mapping multiple values to one column is possible to allow for entities inside an aggregate to have the id of the aggregate as ID or as part of the ID.

The reason for the test failures was that columns get referred to by different ways:
Once per DerivedSqlIdentifier (i.e. with normalized spelling).
And Once per `@Column` annotation.

SqlIdentifier from an `@Column` annotation have always the same spelling, while the normalized version depends on the `Dialect`.

In order to make the tests work for all databases all references to the column in question had to get a `@Column` annotation.
This in turn required the create scripts to also use quoting when the normal case of the database did not match the case chosen in the annotation.

Finally there were some tests that used hand coded SQL which now uses `SqlIdentifier` and an injected `Dialect` to arrive at the correct SQL syntax.

Removed a couple of `@Ignore` annotations that got left in the code.

Original pull request: #182.
2020-01-28 13:55:19 +01:00
Mark Paluch
b3d5f05258 DATAJDBC-386 - Refactor SqlIdentifier.
Fix bind marker rendering for delete by Id.

SqlIdentifier provides now a transform(…) method to transform its content instead of exposing prefix(…) and suffix(…) methods. Composite identifiers are created through SqlIdentifier.from(…) instead of exposing a concat(…) method.

We also now apply identifier normalization only to derived identifiers instead of applying normalization to annotated column and table names. This change requires references to derived field names to honor the appropriate letter casing.

Identifier quotation can be disabled globally, via RelationalMappingContext.setForceQuote(false).

Move SqlIdentifier to relational.core.sql package.

Original pull request: #182.
2020-01-28 13:54:54 +01:00
Jens Schauder
558e7386dc DATAJDBC-386 - Introduce quoting for all database identifier.
All database identifiers, i.e. table names, column names and so on, now get quoted.
For most databases this means they get enclosed with double quotes.
For some databases this makes the the identifiers case sensitive.
In order to minimize the impact we convert identifiers their default letter casing.
This should be upper case according to the SQL standard but isn't for some databases.

The exact behavior regarding quoting and default letter casing gets controlled by a database specific `Dialect`.

Future changes will make the quoting of annotated columns and the default quoting behavior configurable.

Original pull request: #182.
2020-01-28 09:22:17 +01:00
Jens Schauder
09fd0fcbd6 DATAJDBC-234 - Fixes the default query naming and polishing.
The default name now does include the name of the domain class.
The default name now is no longer used when no query with the name specified in the `@Query` annotation is found.

Simplified the unit tests by extracting common functionality and improving naming.
Simplified test configuration.

Original pull request: #180.
2020-01-08 15:40:11 +01:00