X - the type of the managed instancepublic class ManagedInstance<X> extends Object
| Modifier and Type | Field and Description |
|---|---|
static ThreadLocal<LockModeType> |
LOCK_CONTEXT
The current lock mode context.
|
| Constructor and Description |
|---|
ManagedInstance(EntityTypeImpl<X> type,
SessionImpl session,
X instance) |
ManagedInstance(EntityTypeImpl<X> type,
SessionImpl session,
X instance,
ManagedId<? super X> id) |
| Modifier and Type | Method and Description |
|---|---|
void |
cascadeDetach(EntityManagerImpl entityManager)
Cascades the detach operation.
|
boolean |
cascadePersist(EntityManagerImpl entityManager,
ArrayList<Object> processed)
Cascades the persist operation.
|
void |
cascadeRemove(EntityManagerImpl entityManager)
Cascades the remove operation
|
void |
changed()
Marks the instance as may have changed.
|
void |
checkTransients()
Checks that no association of the instance is transient
|
void |
checkUpdated()
Checks if the instance updated.
|
void |
checkVersion(ConnectionImpl connection)
Checks the optimistic lock for the instance.
|
void |
enhanceCollections()
Enhances the collections of the managed instance.
|
boolean |
equals(Object obj) |
boolean |
fillIdValues()
Fills the sequence / table generated values.
|
void |
fireCallbacks(EntityListenerMetadata.EntityListenerType type)
Fires the callbacks.
|
void |
flush(ConnectionImpl connection)
Flushes the state of the instance to the database.
|
void |
flushAssociations(ConnectionImpl connection,
boolean removals,
boolean force)
Flushes the associations.
|
HashSet<JoinedMapping<?,?,?>> |
getAssociationsLoaded()
Returns the associations that are loaded.
|
ManagedId<? super X> |
getId()
Returns the id of the instance.
|
X |
getInstance()
Returns the instance.
|
LockModeType |
getLockMode()
Returns the lock mode of the instance.
|
SessionImpl |
getSession()
Returns the session.
|
Status |
getStatus()
Returns the status.
|
EntityTypeImpl<X> |
getType()
Returns the type.
|
void |
handleAdditions(EntityManagerImpl entityManager)
Handles the entities that have been added.
|
void |
handleOrphans(EntityManagerImpl entityManager)
Handles the entities that have been orphaned.
|
int |
hashCode() |
boolean |
hasInitialId()
Returns if the instance has initial id.
|
boolean |
hasSelfUpdate()
Returns if the instance has self update.
|
void |
incrementVersion(ConnectionImpl connection,
boolean commit)
Increments the version of the instance.
|
boolean |
isJoinLoaded(String attributeName)
Returns if attribute name
attributeNaƶe has been loaded. |
boolean |
isLoading()
Returns if the instance is loading.
|
boolean |
isLoadingFromCache()
Returns if the instance is loading from the cache.
|
boolean |
isRefreshing()
Returns if the instance is refreshing.
|
void |
mergeWith(EntityManagerImpl entityManager,
X entity,
org.apache.commons.lang.mutable.MutableBoolean requiresFlush,
IdentityHashMap<Object,Object> processed)
Merges the instance state with the
entity. |
void |
processJoinedMappings()
Processes the associations.
|
void |
refresh(EntityManagerImpl entityManager,
ConnectionImpl connection,
LockModeType lockMode)
Refreshes the instance from the database.
|
void |
reset()
Resets the change status of the instance.
|
void |
setCache(CacheInstance cacheInstance)
Sets the cache instance
|
void |
setChanged(PluralMapping<?,?,?> association)
Marks the plural association as changed.
|
void |
setJoinLoaded(JoinedMapping<?,?,?> mapping)
Sets the association as loaded.
|
void |
setLoading(boolean loading)
Marks the instance as loading.
|
void |
setLoadingFromCache(boolean loadingFromCache)
Marks the instance as loading loading from the cahce.
|
void |
setOptimisticLock()
Sets the optimistic lock on
|
void |
setRefreshing(boolean refreshing)
Marks the instance as refreshing.
|
void |
setStatus(Status status)
Sets the status.
|
void |
sortLists()
Sorts the list associations.
|
String |
toString() |
boolean |
tryLoadFromCache(PluralAssociationMapping<?,?,?> mapping)
Tries to load the collection from the cache.
|
void |
updateCollectionCache(PluralMapping<?,?,?> mapping)
Updates the collection cache of the managed instance for the mapping
|
public static ThreadLocal<LockModeType> LOCK_CONTEXT
public ManagedInstance(EntityTypeImpl<X> type, SessionImpl session, X instance)
type - the entity type of the instancesession - the sessioninstance - the instancepublic ManagedInstance(EntityTypeImpl<X> type, SessionImpl session, X instance, ManagedId<? super X> id)
type - the entity type of the instancesession - the sessioninstance - the instanceid - the id of the instancepublic void cascadeDetach(EntityManagerImpl entityManager)
entityManager - the entity managerpublic boolean cascadePersist(EntityManagerImpl entityManager, ArrayList<Object> processed)
entityManager - the entity managerprocessed - registry of processed entitiespublic void cascadeRemove(EntityManagerImpl entityManager)
entityManager - the entity managerpublic void changed()
public void checkTransients()
public void checkUpdated()
Only meaningful for external entities as their instances' are not enhanced.
public void checkVersion(ConnectionImpl connection) throws SQLException
connection - the connectionSQLException - thrown in case of an SQL errorpublic void enhanceCollections()
public boolean fillIdValues()
public void fireCallbacks(EntityListenerMetadata.EntityListenerType type)
type - the type of the callbackspublic void flush(ConnectionImpl connection) throws SQLException
connection - the connection to use to flushSQLException - thrown in case of an SQL errorpublic void flushAssociations(ConnectionImpl connection, boolean removals, boolean force) throws SQLException
connection - the connectionremovals - true if the removals should be flushed and false for the additionsforce - true to force, effective only for insertions and for new entities.SQLException - thrown if there is an underlying SQL Exceptionpublic HashSet<JoinedMapping<?,?,?>> getAssociationsLoaded()
public ManagedId<? super X> getId()
public X getInstance()
public LockModeType getLockMode()
public SessionImpl getSession()
public Status getStatus()
public EntityTypeImpl<X> getType()
public void handleAdditions(EntityManagerImpl entityManager)
entityManager - the entity managerpublic void handleOrphans(EntityManagerImpl entityManager)
entityManager - the entity managerpublic boolean hasInitialId()
public boolean hasSelfUpdate()
public void incrementVersion(ConnectionImpl connection, boolean commit) throws SQLException
connection - the connectioncommit - true if version update should be committed immediatelySQLException - thrown in case of an underlying SQL errorpublic boolean isJoinLoaded(String attributeName)
attributeNaƶe has been loaded.attributeName - the name of the attributepublic boolean isLoading()
public boolean isLoadingFromCache()
public boolean isRefreshing()
public void mergeWith(EntityManagerImpl entityManager, X entity, org.apache.commons.lang.mutable.MutableBoolean requiresFlush, IdentityHashMap<Object,Object> processed)
entity.entityManager - the entity managerentity - the entity to mergerequiresFlush - if an implicit flush is requiredprocessed - registry of processed entitiespublic void processJoinedMappings()
public void refresh(EntityManagerImpl entityManager, ConnectionImpl connection, LockModeType lockMode)
entityManager - the entity managerconnection - the connectionlockMode - the lock modepublic void reset()
public void setCache(CacheInstance cacheInstance)
cacheInstance - the cache instancepublic void setChanged(PluralMapping<?,?,?> association)
association - the association that has changedpublic void setJoinLoaded(JoinedMapping<?,?,?> mapping)
mapping - the associationpublic void setLoading(boolean loading)
loading - loading to setpublic void setLoadingFromCache(boolean loadingFromCache)
loadingFromCache - loading to setpublic void setOptimisticLock()
public void setRefreshing(boolean refreshing)
refreshing - refreshing to setpublic void setStatus(Status status)
status - the status to setpublic void sortLists()
public boolean tryLoadFromCache(PluralAssociationMapping<?,?,?> mapping)
mapping - the mapping of the collectionpublic void updateCollectionCache(PluralMapping<?,?,?> mapping)
mapping - the mapping to updateCopyright © 2012 Batoo Software & Consultancy. All Rights Reserved.