nl.knowledgeplaza.util.jpa
Class EntityManagerExtender

java.lang.Object
  extended by nl.knowledgeplaza.util.jpa.EntityManagerExtender
All Implemented Interfaces:
java.lang.reflect.InvocationHandler
Direct Known Subclasses:
EclipselinkEntityManagerExtender

public class EntityManagerExtender
extends java.lang.Object
implements java.lang.reflect.InvocationHandler

The disconnected usage of the EM requires that prior to storing or removing the toplevel entity a clear must be called, then the toplevel entity is stored/removed and is propogated down. In order to propogate down, any entity must be reachable. This works fine for storing, however removed entities are not reachable anymore and the clear has cleared the EM's list of removed entities. Because of this, removed subentities are in fact not removed, but where cleared by the clear call. To work around this, this wrapper was created: 1. keep a separate administration of removed enitit

Author:
toeu

Field Summary
static java.lang.Object CLEARED_ENTITIES
           
static java.lang.String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Constructor Summary
protected EntityManagerExtender(javax.persistence.EntityManager em)
           
 
Method Summary
 void clearAllRemovedEntities()
           
 void clearDelayedMerges()
           
 void clearDelayedPersists()
           
 void clearRemovedEntities()
           
static void executeNextClearWithoutClearingRemovedEntities(javax.persistence.EntityManager entityManager)
           
 java.util.List getAllRemovedEntities()
          AllRemovedEntities: the EM will erase its removed entities upon a "clear"
 java.util.List getDelayedMerges()
          DelayedMerges
 java.util.List getDelayedPersists()
          DelayedPersists
 javax.persistence.EntityManager getEntityManager()
          EntityManager
 java.util.List getRemovedEntities()
          RemovedEntities: the entities that are also remember by the wrapped EM
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
           
static javax.persistence.EntityManager wrap(javax.persistence.EntityManager em)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCECODE_VERSION

public static final java.lang.String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values

CLEARED_ENTITIES

public static final java.lang.Object CLEARED_ENTITIES
Constructor Detail

EntityManagerExtender

protected EntityManagerExtender(javax.persistence.EntityManager em)
Method Detail

getEntityManager

public javax.persistence.EntityManager getEntityManager()
EntityManager


getAllRemovedEntities

public java.util.List getAllRemovedEntities()
AllRemovedEntities: the EM will erase its removed entities upon a "clear"


clearAllRemovedEntities

public void clearAllRemovedEntities()

getRemovedEntities

public java.util.List getRemovedEntities()
RemovedEntities: the entities that are also remember by the wrapped EM


clearRemovedEntities

public void clearRemovedEntities()

getDelayedMerges

public java.util.List getDelayedMerges()
DelayedMerges


clearDelayedMerges

public void clearDelayedMerges()

getDelayedPersists

public java.util.List getDelayedPersists()
DelayedPersists


clearDelayedPersists

public void clearDelayedPersists()

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Throws:
java.lang.Throwable

wrap

public static javax.persistence.EntityManager wrap(javax.persistence.EntityManager em)

executeNextClearWithoutClearingRemovedEntities

public static void executeNextClearWithoutClearingRemovedEntities(javax.persistence.EntityManager entityManager)


Copyright © 2010. All Rights Reserved.