@ -62,7 +62,38 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
@@ -62,7 +62,38 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
@ -92,6 +123,10 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
@@ -92,6 +123,10 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
Assert.notNull(entityCallbacks,"Callbacks must not be null.");
@ -297,16 +332,6 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
@@ -297,16 +332,6 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
@ -351,9 +376,11 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
@@ -351,9 +376,11 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
@ -373,7 +400,7 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
@@ -373,7 +400,7 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
@ -389,7 +416,6 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
@@ -389,7 +416,6 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
@ -409,25 +435,9 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
@@ -409,25 +435,9 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
@ -119,7 +119,8 @@ public class JdbcRepositoryFactory extends RepositoryFactorySupport {
@@ -119,7 +119,8 @@ public class JdbcRepositoryFactory extends RepositoryFactorySupport {
@ -156,8 +157,11 @@ public class JdbcRepositoryFactory extends RepositoryFactorySupport {
@@ -156,8 +157,11 @@ public class JdbcRepositoryFactory extends RepositoryFactorySupport {
@ -54,6 +55,10 @@ public class RelationalAuditingCallback implements BeforeConvertCallback, Ordere
@@ -54,6 +55,10 @@ public class RelationalAuditingCallback implements BeforeConvertCallback, Ordere
@ -5,7 +5,7 @@ This chapter points out the specialties for repository support for JDBC. This bu
@@ -5,7 +5,7 @@ This chapter points out the specialties for repository support for JDBC. This bu
You should have a sound understanding of the basic concepts explained there.
[[jdbc.why]]
=== Why Spring Data JDBC?
== Why Spring Data JDBC?
The main persistence API for relational databases in the Java world is certainly JPA, which has its own Spring Data module.
Why is there another one?
@ -36,7 +36,7 @@ If you do not like that, you should code your own strategy.
@@ -36,7 +36,7 @@ If you do not like that, you should code your own strategy.
Spring Data JDBC offers only very limited support for customizing the strategy with annotations.
[[jdbc.domain-driven-design]]
=== Domain Driven Design and Relational Databases.
== Domain Driven Design and Relational Databases.
All Spring Data modules are inspired by the concepts of "`repository`", "`aggregate`", and "`aggregate root`" from Domain Driven Design.
These are possibly even more important for Spring Data JDBC, because they are, to some extent, contrary to normal practice when working with relational databases.
@ -62,7 +62,7 @@ WARNING: In the current implementation, entities referenced from an aggregate ro
@@ -62,7 +62,7 @@ WARNING: In the current implementation, entities referenced from an aggregate ro
You can overwrite the repository methods with implementations that match your style of working and designing your database.
[[jdbc.java-config]]
=== Annotation-based Configuration
== Annotation-based Configuration
The Spring Data JDBC repositories support can be activated by an annotation through Java configuration, as the following example shows:
.Spring Data JDBC repositories using Java configuration
@ -563,9 +563,9 @@ Note that the type used for prefixing the statement name is the name of the aggr
@@ -563,9 +563,9 @@ Note that the type used for prefixing the statement name is the name of the aggr
|===
[[jdbc.events]]
== Events and Callback
== Lifecycle Events
Spring Data JDBC triggers events that get published to any matching `ApplicationListener` and `EntityCallback` beans in the application context.
Spring Data JDBC triggers events that get published to any matching `ApplicationListener` beans in the application context.
For example, the following listener gets invoked before an aggregate gets saved:
====
@ -586,33 +586,59 @@ public ApplicationListener<BeforeSave> timeStampingSaveTime() {
@@ -586,33 +586,59 @@ public ApplicationListener<BeforeSave> timeStampingSaveTime() {
----
====
The following table describes the available events and callbacks:
The following table describes the available events:
| After an aggregate root gets created from a database `ResultSet` and all its property get set.
|===
WARNING: Lifecycle events depend on an `ApplicationEventMulticaster`, which in case of the `SimpleApplicationEventMulticaster` can be configured with a `TaskExecutor`, and therefore gives no guarantees when an Event is processed.