|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.wamblee.persistence.JpaMergeSupport
public class JpaMergeSupport
Support for merging of JPA entities. This utility allows the result of a merge (modifications of primary key and/or version) to be merged back into the argument that was merged. As a result, the merged entity can be reused and the application is not forced to use the new version that was returned from the merge. The utility traverses the object graph based on the public getter methods. Therefore, care should be taken with this utility as usage could lead to recursively loading all objects reachable from the given object. Then again, this utility is for working with detached objects and it would, in general, be bad practice to work with detached objects that still contain unresolved lazy loaded relations and with detached objects that implicitly refer to almost the entire datamodel. This utility best supports a service oriented design where interaction is through service interfaces where each service has its own storage isolated from other services. That would be opposed to a shared data design with many services acting on the same data.
| Constructor Summary | |
|---|---|
JpaMergeSupport()
Constructs the object. |
|
| Method Summary | ||
|---|---|---|
static void |
merge(Object aMerged,
Object aPersistent)
As #merge(Persistent) but with a given template. |
|
static void |
processList(List aMerged,
List aPersistent,
List<ObjectElem> aProcessed)
Process the persistent objects in the collections. |
|
static
|
processMap(Map<Key,Value> aMerged,
Map<Key,Value> aPersistent,
List<ObjectElem> aProcessed)
Process the Map objects in the collections. |
|
static void |
processPersistent(Object aMerged,
Object aPersistent,
List<ObjectElem> aProcessed)
Copies primary keys and version from the result of the merged to the object that was passed to the merge operation. |
|
static void |
processSet(Set aMerged,
Set aPersistent,
List<ObjectElem> aProcessed)
Process the persistent objects in sets. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JpaMergeSupport()
| Method Detail |
|---|
public static void merge(Object aMerged,
Object aPersistent)
#merge(Persistent) but with a given template. This method can
be accessed in a static way.
aMerge - The result of the call to EntityManager.merge(Object).aPersistent - Object that was passed to EntityManager.merge(Object).
public static void processPersistent(Object aMerged,
Object aPersistent,
List<ObjectElem> aProcessed)
Persistent and applies the
same rules to objects in maps and sets as well (i.e. recursively).
aPersistent - Object whose primary key and version are to be set.aMerged - Object that was the result of the merge.aProcessed - List of already processed Persistent objects of the persistent
part.
public static void processList(List aMerged,
List aPersistent,
List<ObjectElem> aProcessed)
aPersistent - Collection in the original object.aMerged - Collection as a result of the merge.aProcessed - List of processed persistent objects.
public static void processSet(Set aMerged,
Set aPersistent,
List<ObjectElem> aProcessed)
aPersistent - Collection in the original object.aMerged - Collection as a result of the merge.aProcessed - List of processed persistent objects.
public static <Key,Value> void processMap(Map<Key,Value> aMerged,
Map<Key,Value> aPersistent,
List<ObjectElem> aProcessed)
aPersistent - Collection in the original object.aMerged - Collection as a result of the merge.aProcessed - List of processed persistent objects.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||