From 22b1f6fa1b69bd4bdb72d2a2a399fe0ed6ab330e Mon Sep 17 00:00:00 2001 From: Thomas Darimont Date: Tue, 30 Jul 2013 13:46:48 +0200 Subject: [PATCH] DATAJPA-344 - Explain about save strategy repositories in ref doc. Added section "entity persistence" to the reference documentation explaining the supported strategies for the detection of new-entities. Original pull request: #32. --- src/docbkx/jpa.xml | 77 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/src/docbkx/jpa.xml b/src/docbkx/jpa.xml index eed83c1a8..a1ae50e23 100644 --- a/src/docbkx/jpa.xml +++ b/src/docbkx/jpa.xml @@ -154,6 +154,83 @@ class ApplicationConfig { +
+ Persisting entities + +
+ Saving entities + + Saving an entity can be performed via the + CrudRepository.save(…)-Method. It will persist or merge the + given entity using the underlying JPA + EntityManager. If the entity has not been + persisted yet Spring Data JPA will save the entity via a call to the + entityManager.persist(…)-Method, otherwise the + entityManager.merge(…)-Method will be called. + + + Entity state detection strategies + + Spring Data JPA offers the following strategies to detect + whether an entity is new or not: + + + Options for detection whether an entity is new in Spring Data + JPA + + + + + + + + + Id-Property inspection (default) + + By default Spring Data JPA inspects the Id-Property of + the given Entity. If the Id-Property is null, + then the entity will be assumed as new, otherwise as not + new. + + + + Implementing + Persistable + + If an entity implements the + Persistable interface, Spring + Data JPA will delegate the new-detection to the + isNew - Method of the Entity. See the + JavaDoc + for details. + + + + Implementing + EntityInformation + + One can customize the + EntityInformation abstraction + used in the SimpleJpaRepository + implementation by creating a subclass of + JpaRepositoryFactory and overriding the + getEntityInformation-Method + accordingly. One then has to register the custom + implementation of JpaRepositoryFactory + as a Spring bean. Note that this should be rarely necessary. + See the JavaDoc + for details. + + + +
+
+
+
+
Query methods