Commit Graph

103 Commits

Author SHA1 Message Date
Jens Schauder
0445aa61db DATAJDBC-238 - JdbcRepositoryFactory.getEntityInformation never returns null.
Instead it throws an exception as this is required by the interface it implements.
2018-07-20 13:49:43 +02:00
Jens Schauder
8ee15fb1fd DATAJDBC-237 - Removed @since annotations.
@since annotation are only supposed to be used for classes introduced after the initial release.
2018-07-20 13:39:51 +02:00
Mark Paluch
12d539a017 DATAJDBC-227 - Polishing.
Return List<DbChange<?>> in RelationalEntityWriters so AggregateChange can be assembled in less places to reduce the number of abstractions per method. Change ResultOrException in FunctionCollector to static class so instances no longer retain a reference to their enclosing class. Fix DbAction generics in AggregateChange. Replace simple constructors with Lombok usage. Javadoc, typos, formatting.

Original pull request: #79.
2018-07-19 15:34:01 +02:00
Jens Schauder
bdefd3da9a DATAJDBC-227 - Refactored JdbcEntityWriter and DbActions.
JdbcEntityWriter and JdbcDeleteEntityWriter now use an iterative approach based on PersistentPropertyPath instead of a recursive one.

DbAction is now split into multiple interfaces representing different variants of actions.
The implementations are simple value types without any implementation inheritance hierarchy.
All elements of a DbAction implementation are not null making usage and construction of instances much easier.

Original pull request: #79.
2018-07-19 15:33:46 +02:00
Jens Schauder
c412aad6b8 DATAJDBC-235 - Polishing.
Corrected nullability annotations.
Minor improvements in Javadoc.
Added @author tags.
Removed unused imports.
2018-07-19 10:38:52 +02:00
Mark Paluch
2c5489b070 DATAJDBC-235 - Incorporate feedback from review.
Refactor ResultSetParameterValueProvider into Function<Parameter, Object>. Remove unnecessary assertions.
2018-07-19 10:38:52 +02:00
Mark Paluch
fb858bf1b1 DATAJDBC-235 - Add support for configurable conversion.
We now support configurable conversion by introducing CustomConversions and RelationalConverter. CustomConversions is a registry for converters that should be applied on a per-type basis for properties. CustomConversions is typically registered as bean and fed into RelationalMappingContext and the newly introduced RelationalConverter to consider simple types and conversion rules.

RelationalConverter with its implementation BasicRelationalConverter encapsulates conversion infrastructure such as EntityInstantiator, CustomConversions, and MappingContext that is required during relational value conversion. BasicRelationalConverter is responsible for simple value conversion and entity instantiation to pull related code together. It's not in full charge of row result to object mapping as this responsibility remains as part of DataAccessStrategy.

This change supersedes and removes ConversionCustomizer.
2018-07-19 10:38:52 +02:00
Oliver Gierke
95d316367b DATAJDBC-232 - Adapt code to changes to support immutable entities.
We now treat all properties of an entity mutable and continue to use the reflective PersistentPropertyAccessor implementation to make sure we don't break the old behavior of reflectively mutating immutable objects.

This is a workaround for now and has to be replaced by more exhaustive changes later.

Related tickets: DATACMNS-1322.
2018-07-13 16:50:30 +02:00
Oliver Gierke
9991946d92 DATAJDBC-226 - Renamed all types named Jdbc… in relational package Relational…. 2018-06-22 15:40:32 +02:00
Oliver Gierke
8a67e52b61 DATAJDBC-226 - Extracted packages not directly tied to JDBC into separate package. 2018-06-22 15:33:13 +02:00
Jens Schauder
0a0e774129 DATAJDBC-137 - Fixes warnings and improves Javadoc.
All packages now use @NoNullApi.
All warnings related to that fixed, except a few cases where upstream annotations are simply wrong.
Added null checks.
Fixed generic types where possible.
Improved Javadoc.
Code Formatting.
2018-06-11 16:15:52 +02:00
Mark Paluch
b9c6b8b943 DATAJDBC-102 - Polishing.
Pull entity instantiation into a single method.

Original pull request: #68.
2018-06-04 16:12:59 +02:00
Jens Schauder
0ebb4a7799 DATAJDBC-102 - Determine the EntityInstantiator to be used dynamically.
Replaced the direct use of EntityInstantiator with EntityInstantiators.
Moved it into the MappingContext because instantiation is part of the mapping process.

Original pull request: #68.
2018-06-04 16:12:59 +02:00
Oliver Gierke
fca2ef6629 DATAJDBC-137 - Improve EntityInformation usage.
Moved to both the usage of the newly introduced PersistentEntity.isNew(…) and identifier lookups via PersistentEntity instead of using a custom EntityInformation implementation. JdbcRepositoryFactory now creates a PersistentEntityInformation, SimpleJdbcRepository simply works with a PersistentEntity.

Removed references to EntityInformation (a repository subsystem concept) from the template implementation. Removed BasicJdbcPersistentEntity and its tests entirely. JdbcAuditingEventListener is now using an IsNewAwareAuditingHandler.

Related tickets: DATACMNS-1333.
2018-05-31 22:28:06 +02:00
Jens Schauder
b4b6625d50 DATAJDBC-207 - Default NamingStrategy is now Snake Case.
Moved the implementation from the DelimiterNamingStrategy into the NamingStrategy.
Dropped the support for different separators, since there is no good way to support it in the default implementations of an interface.
A getSeparator() method would bleed into the public API.
Also the added value of that flexibility seems limited.

During migration of the various test it became obvious that SqlGeneratorUnitTests was broken since test failures happend on a worker thread not on the main test thread.
This is fixed as well with this commit.
2018-05-23 15:24:35 -05:00
Jens Schauder
0460f2f509 DATAJDBC-188 - Ensure proper behavior of delete logic.
No behavior changed.
Added tests on various levels for deleting entities with references to other entities.
2018-05-23 15:15:50 -05:00
Jens Schauder
01478cc53d DATAJDBC-143 - Removed domain type parameter form JdbcEntityOperations.save().
Such a parameter would only make sense with inheritance and we don't support inheritance at all in the moment.
Anything we need in order to support inheritance should be added once we do support inheritance.
2018-05-23 15:05:09 -05:00
Oliver Gierke
e4de5701d4 DATAJDBC-138 - Polishing.
Moved all types from mapping.model into model to align with the setup of other Spring Data modules.

Original pull request: #67.
2018-05-18 16:35:13 +02:00
Jens Schauder
bd7401b665 DATAJDBC-138 - Improve package structure and naming.
Moved SimpleJdbcRepository into support package.
Moved mapping package under core.
Renamed JdbcEntityOperations to JdbcAggregateOperations.
2018-05-18 16:35:13 +02:00
Oliver Gierke
d0a8af21a3 DATAJDBC-137 - Polishing.
Moved the dependency to NamedParameterJdbcOperations out of JdbcMappingContext. This revealed that despite the DataAccessStrategy abstraction, there are a couple of places in the query execution subsystem that work with a plain NamedParameterJdbcOperations instance, so that we now have to carry that around all the way from the repository factory bean. Improving that is subject for further changes.

A bit of JavaDoc and generics polish here and there.
2018-05-18 15:11:27 +02:00
Oliver Gierke
fbc271a83a DATAJDBC-106 - Polishing.
Moved annotation processing of @Table and @Column into metamodel classes so that the NamingStrategy is only responsible for generic fallbacks. Allow @Column to be used as meta-annotation.
2018-05-18 13:57:46 +02:00
Oliver Gierke
eab63d8848 DATAJDBC-137 - Cleanups in the repository and repository.support packages. 2018-05-18 12:30:38 +02:00
Jens Schauder
fe98964d72 DATAJDBC-216 - Polishing.
Simplified code by using constructor injection plus Lombok.
Removed superfluous handling of BeforeSave events with null entity.

Original pull request: #71.
2018-05-18 07:53:45 +02:00
Kazuki Shimizu
0c863eb180 DATAJDBC-216 - Support @Id property primitive type for auditing.
The new check is now properly done using Spring Data meta Informationen.

Original pull request: #71.
2018-05-18 07:52:02 +02:00
Jens Schauder
46a07ac9f7 DATAJDBC-106 - Polishing.
Formatting and Javadoc.

Original pull request: #65
2018-05-17 16:07:57 +02:00
Kazuki Shimizu
cd7403907a DATAJDBC-106 - Support to specify a database object names using annotations.
@Table and @Column annotation added for configuring table and column names.

Original pull request: #65.
2018-05-17 16:06:40 +02:00
Oliver Gierke
35fa0d184c DATAJDBC-212 - Adapt to SpEL extension API changes in Spring Data Commons.
Related tickets: DATACMNS-1260.
2018-05-15 11:10:08 +02:00
Jens Schauder
41e31b1916 DATAJDBC-201 - Reduced logging for builds.
Set logging level to WARN.
Removed a System.out call.

The detail loggers are still in the logback.xml as comments to be used for debugging and demonstration purposes.
2018-04-17 15:37:28 +02:00
Jens Schauder
53eea0202a DATAJDBC-204 - Polishing.
Extracted ApplicationContext and Repository construction into method in order to make the actual test stand out more.
Split a test in two.
JavaDoc.
Code formatting.
Removed access modifiers in tests.
2018-04-17 13:07:24 +02:00
Kazuki Shimizu
92cd333854 DATAJDBC-204 - Support for annotation based auditing.
When enabled by using @EnableJdbcAuditing entities will get properties annotated with

* @CreatedBy
* @CreatedDate
* @LastModifiedBy
* @LastModifiedDate

updated when saved.

Original pull request: #64.
2018-04-17 12:54:29 +02:00
Jens Schauder
cc477f8c89 DATAJDBC-200 - Renamed Events to have an 'Event' suffix.
Original pull request: #60.
2018-04-13 12:06:56 +02:00
Jens Schauder
3f89062bc1 DATAJDBC-199 - Fix @since JavaDoc comments. 2018-04-12 16:32:25 +02:00
Mark Paluch
eb0f62181e DATAJDBC-197 - Polishing.
Rename AfterCreation event to AfterLoadEvent to align with other Spring Data modules. Add missing generics. Remove since tags pointing to version 2.0. Slightly tweak tests.

Original pull request: #58.
2018-04-11 16:19:37 +02:00
Jens Schauder
fbac3a5529 DATAJDBC-197 - Repositories find methods now emit AfterLoadEvents as intended.
Event publishing moved into the JdbcEntityTemplate in order to ensure events for AggregateRoots.

Removed superfluous AggregateChange from AfterCreation event.

Original pull request: #58.
2018-04-11 16:19:12 +02:00
Jens Schauder
dba9d3f4ee DATAJDBC-195 - SqlGenerator now uses upper ase key words. 2018-04-10 10:30:23 +02:00
Jens Schauder
c7958f82a3 DATAJDBC-178 - Polishing.
Renamed MyBatisNamingStrategy into NamespaceStrategy.
This avoids the confusion with the existing NamingStrategy.

Introduced a default instance.
Added a method creating a proper DataAccessStrategy with a NamespaceStrategy.

JavaDoc.

Original pull request: #44.
2018-04-03 14:35:43 +02:00
Kazuki Shimizu
45a6d3467a DATAJDBC-178 - Allow customizing the MyBatis namespace.
The MyBatis namespace used can now be customised by providing a NamespaceStrategy to the MyBatisDataAccessStrategy.

Original pull request: #44.
2018-04-03 14:26:03 +02:00
Christoph Strobl
db2b44db63 DATAJDBC-155 - Polishing.
Update Javadoc, assert state, default nullable properties in afterPropertiesSets and add tests.

Original pull request: #54.
2018-03-27 14:37:24 +02:00
Jens Schauder
aaae9a5f5c DATAJDBC-155 - Simplified construction of JdbcRepositoryFactory.
Made the DefaultDataAccessStrategy actually the default for JdbcRepositoryFactoryBean.
Therefore the injection of a strategy is optional.

Simplified constructors of DefaultDataAccessStrategy.
Created factory method to construct a correct DataAccessStrategy for use with MyBatis.

Did some untangling in the test application context configurations.

Original pull request: #54.
2018-03-27 14:36:07 +02:00
Jens Schauder
e477d763c1 DATAJDBC-189 - Polishing.
Removed DefaultNamingStrategy since we don't have GA release breaking APIs is still ok.
Introduced an instance of NamingStrategy so we don't have to create a new class whereever we just want the default implementation.

JavaDoc.
Formatting

Original pull request: #36.
2018-03-23 14:11:26 +01:00
Michael J. Simons
a6e4380789 DATAJDBC-189 - Move default implementation to NamingStrategy
This makes it nicer to overwrite certain aspects with a lambda instead of an anonymous class. Brings the naming strategy in line with pairs like WebMvcConfigurer / WebMvcConfigurerAdapter.

Original pull request: #36.
2018-03-23 13:00:40 +01:00
Jens Schauder
b1115833ab DATAJDBC-184 - Polishing.
Minor changes to JavaDoc and formatting.

Original pull request: #49.
2018-03-23 12:47:38 +01:00
Kazuki Shimizu
924bb55394 DATAJDBC-184 - Support the delimiter character naming strategy.
Original pull request: #49.
2018-03-23 12:45:06 +01:00
Jens Schauder
46f65149b8 DATAJDBC-186 - Polishing.
JavaDoc.
2018-03-21 11:45:11 -05:00
Jens Schauder
f7274a2efa DATAJDBC-186 - Removed requirement for id properties.
It is now ok for an entity to be “new” after saving.
We now only check that an entity is not new when the id is provided by the database.
If in such a case the entity is still “new” after saving it basically means obtaining the id from JDBC and setting it in the entity failed.

Removed need for entities in maps to have an id.

Together these changes simplify the requirements for Map values, which now can be value objects.
2018-03-21 11:44:59 -05:00
Jens Schauder
8885ce342b DATAJDBC-183 - Polishing.
Removed calls to System.out.
Formatting.
Import order.
2018-03-21 11:42:58 -05:00
Jens Schauder
cb302e90a6 DATAJDBC-183 - Using dedicated class for handling map entries.
Instead of using Map.Entry we now use a dedicated class to hold key and value of a map entry.
This avoids side effects from the implementation of Map.Entry.

Replaced call to saveReferencedEntities with insertReferencedEntities which is simpler but equivalent since referenced entities always get only inserted, never updated.

Removed superfluous methods resulting from that change.
2018-03-21 11:42:46 -05:00
Jens Schauder
31eeba743f DATAJDBC-142 - Using getName instead of getColumnName for constructing PropertyPaths. 2018-03-21 11:40:18 -05:00
Jens Schauder
964f319ae6 DATAJDBC-166 - Polishing.
Formatting.
Import order.
Use of AssertJ.
2018-03-21 11:37:32 -05:00
Jens Schauder
a2b7699256 DATAJDBC-166 - Allow registration of RowMappers based on result type.
RowMapper can be configured either via the @Query(rowMapperClass = …​.) or by registerign a RowMapperMap bean and register RowMapper per method return type.

                @Bean
                RowMapperMap rowMappers() {
                        return new ConfigurableRowMapperMap() //
                                        .register(Person.class, new PersonRowMapper()) //
                                        .register(Address.class, new AddressRowMapper());
                }

When determining the RowMapper to use for a method the following steps are followed based on the return type of the method:

1. If the type is a simple type no RowMapper is used. Instead the query is expected to return a single row with a single column and a conversion to the return type is applied to that value.

2. The entity classes in the RowMapperMap are iterated until one is found that is a superclass or interface of the return type in question. The RowMapper registered for that class is used. Iterating happens in the order of registration, so make sure to register more general types after specific ones.

If applicable wrapper type like collections or Optional are unwrapped. So a return type of Optional<Person> will use the type Person in the steps above.
2018-03-21 11:37:05 -05:00