@ -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.
You should have a sound understanding of the basic concepts explained there.
[[jdbc.why]]
[[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.
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?
Why is there another one?
@ -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.
Spring Data JDBC offers only very limited support for customizing the strategy with annotations.
[[jdbc.domain-driven-design]]
[[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.
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.
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
You can overwrite the repository methods with implementations that match your style of working and designing your database.
You can overwrite the repository methods with implementations that match your style of working and designing your database.
[[jdbc.java-config]]
[[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:
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
.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
|===
|===
[[jdbc.events]]
[[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:
For example, the following listener gets invoked before an aggregate gets saved:
====
====
@ -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.