Files
spring-data-examples/jdbc/basics
Oliver Gierke 74d947e951 #313 - Polishing.
Tweaking indentation in pom.xml to use tabs. Switch to upgrade to Spring Data release train Lovelace to simplify dependency declarations.

Import order. Copyright years. Formatting.

Original pull request: #324.
2018-02-22 13:41:01 +01:00
..
2018-02-22 13:41:01 +01:00
2018-02-22 13:41:01 +01:00

== Spring Data JDBC basics


=== SimpleEntityTests

This example demonstrate basic usage of JDBC based repositories.

* The `SimpleEntityTests` demonstrate CRUD operations for an entity without references, just simple properties of various types.

* The `CategoryContext` shows how to configure an application context so that Spring Data JDBC can create repositories.

* The `ApplicationListener` registered in `CategoryContext` demonstrate how to react to events published by Spring Data JDBC and how entities can get manipulated in such event listeners.

=== AggregateTests

This example demonstrates various ways to bend what the standard mapping of Spring Data JDBC can do.

* `AggregateContext.idSetting()` registers an `ApplicationListener` to implement a custom id generation strategy for `LegoSet` and `Manual`.

* `AggregateContext.namingStrategy()` registers a custom `NamingStrategy` in order to map property and class names to database columns and tables.

* The `minimumAge` and `maximumAge` properties show a way to use types which don't have direct mapping to a SQL type, by marking them with `@Transient` and having converted properties for Spring Data JDBC to use.

* The `models` attribute demonstrate mapping of a `Map<simple type, entity>`. It does work out of the box, but in this case the the key of the map should be one attribute of the entity.
This is achieved by providing a custom `NamingStrategy` which maps both to the same database column.

* When the database returns a data type for query which Spring Data JDBC doesn't map out of the box a custom conversion can be registered using a `ConversionCustomizer` as demonstrated in `AggregateContext.conversionCustomizer()`.