Module org.eclipse.persistence.core
Class DynamicEntityImpl
- java.lang.Object
-
- org.eclipse.persistence.internal.dynamic.DynamicEntityImpl
-
- All Implemented Interfaces:
ChangeTracker,DynamicEntity,PersistenceEntity,FetchGroupTracker
public abstract class DynamicEntityImpl extends Object implements DynamicEntity, PersistenceEntity, ChangeTracker, FetchGroupTracker
This abstract class is used to represent an entity which typically is not realized in Java code. In combination with the DynamicClassLoader ASM is used to generate subclasses that will work within EclipseLink's framework. Since no concrete fields or methods exist on this class the mappings used must be customized to use a custom AttributeAccessor (ValuesAccessor).Type/Property Meta-model: This dynamic entity approach also includes a meta-model facade to simplify access to the types and property information so that clients can more easily understand the model. Each
DynamicTypeImplwraps the underlying EclipseLink relational-descriptor and theDynamicPropertiesManagerwraps each mapping. The client application can use these types and properties to facilitate generic access to the entity instances and are required for creating new instances as well as for accessing the Java class needed for JPA and EclipseLink native API calls.- Since:
- EclipseLink 1.2
- Author:
- dclarke, mnorman
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDynamicEntityImpl.PropertyWrapper
-
Field Summary
Fields Modifier and Type Field Description protected CacheKeycacheKeyprotected Map<String,DynamicEntityImpl.PropertyWrapper>propertiesMap
-
Constructor Summary
Constructors Modifier Constructor Description protectedDynamicEntityImpl()Instantiates a new dynamic entity impl.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CacheKey_persistence_getCacheKey()FetchGroup_persistence_getFetchGroup()Return the fetch group being trackedObject_persistence_getId()PropertyChangeListener_persistence_getPropertyChangeListener()PUBLIC: Return the PropertyChangeListener for the object.Session_persistence_getSession()Return the session for the object.boolean_persistence_isAttributeFetched(String attribute)Return true if the attribute is in the fetch group being tracked.void_persistence_resetFetchGroup()Reset all attributes of the tracked object to the un-fetched state with initial default values.void_persistence_setCacheKey(CacheKey cacheKey)void_persistence_setFetchGroup(FetchGroup group)Set a fetch group to be tracked.void_persistence_setId(Object pk)void_persistence_setPropertyChangeListener(PropertyChangeListener listener)PUBLIC: Set the PropertyChangeListener for the object.void_persistence_setSession(Session session)Set true if the fetch group attributes should be refreshedvoid_persistence_setShouldRefreshFetchGroup(boolean shouldRefreshFetchGroup)Set true if the fetch group attributes should be refreshed.boolean_persistence_shouldRefreshFetchGroup()Return true if the fetch group attributes should be refreshed.abstract DynamicPropertiesManagerfetchPropertiesManager()Fetch properties manager.<T> Tget(String propertyName)Return the persistence value for the given property as the specified type.Map<String,DynamicEntityImpl.PropertyWrapper>getPropertiesMap()Gets the properties map.DynamicTypeImplgetType()Gets internal impl class ofDynamicType.booleanisSet(String propertyName)Discover if a property has a persistent valueprotected voidpostConstruct()Post construct.DynamicEntityset(String propertyName, Object value)Set the persistence value for the given property to the specified valueDynamicEntityset(String propertyName, Object value, boolean firePropertyChange)Sets the.StringtoString()String representation of the dynamic entity using the entity type name and the primary key values - something like {Emp 10} or {Phone 234-5678 10}.
-
-
-
Field Detail
-
propertiesMap
protected Map<String,DynamicEntityImpl.PropertyWrapper> propertiesMap
-
cacheKey
protected CacheKey cacheKey
-
-
Method Detail
-
fetchPropertiesManager
public abstract DynamicPropertiesManager fetchPropertiesManager()
Fetch properties manager.- Returns:
- the dynamic properties manager
-
getPropertiesMap
public Map<String,DynamicEntityImpl.PropertyWrapper> getPropertiesMap()
Gets the properties map.- Returns:
- the properties map
-
postConstruct
protected void postConstruct()
Post construct.
-
getType
public DynamicTypeImpl getType() throws DynamicException
Gets internal impl class ofDynamicType.- Returns:
- Dynamic type of this entity
- Throws:
DynamicException- if type is null
-
get
public <T> T get(String propertyName) throws DynamicException
Description copied from interface:DynamicEntityReturn the persistence value for the given property as the specified type. In the case of relationships, this call will populate lazy-loaded relationships- Specified by:
getin interfaceDynamicEntity- Type Parameters:
T- generic type of the property (if not provided, assume Object). If the property cannot be cast to the specific type, aDynamicExceptionwill be thrown.- Parameters:
propertyName- the name of a mapped property If the property cannot be found, aDynamicExceptionwill be thrown.- Returns:
- persistent value or relationship container of the specified type
- Throws:
DynamicException
-
isSet
public boolean isSet(String propertyName) throws DynamicException
Description copied from interface:DynamicEntityDiscover if a property has a persistent value- Specified by:
isSetin interfaceDynamicEntity- Parameters:
propertyName- the name of a mapped property If the property cannot be found, aDynamicExceptionwill be thrown.- Returns:
- true if the property has been set
- Throws:
DynamicException
-
set
public DynamicEntity set(String propertyName, Object value) throws DynamicException
Description copied from interface:DynamicEntitySet the persistence value for the given property to the specified value- Specified by:
setin interfaceDynamicEntity- Parameters:
propertyName- the name of a mapped property If the property cannot be found, aDynamicExceptionwill be thrown.value- the specified object- Returns:
- the same DynamicEntity instance
- Throws:
DynamicException
-
set
public DynamicEntity set(String propertyName, Object value, boolean firePropertyChange) throws DynamicException
Sets the.- Parameters:
propertyName- the property namevalue- the valuefirePropertyChange- the fire property change- Returns:
- the dynamic entity
- Throws:
DynamicException- the dynamic exception
-
_persistence_getId
public Object _persistence_getId()
- Specified by:
_persistence_getIdin interfacePersistenceEntity
-
_persistence_setId
public void _persistence_setId(Object pk)
- Specified by:
_persistence_setIdin interfacePersistenceEntity
-
_persistence_getCacheKey
public CacheKey _persistence_getCacheKey()
- Specified by:
_persistence_getCacheKeyin interfacePersistenceEntity
-
_persistence_setCacheKey
public void _persistence_setCacheKey(CacheKey cacheKey)
- Specified by:
_persistence_setCacheKeyin interfacePersistenceEntity
-
_persistence_getPropertyChangeListener
public PropertyChangeListener _persistence_getPropertyChangeListener()
Description copied from interface:ChangeTrackerPUBLIC: Return the PropertyChangeListener for the object.- Specified by:
_persistence_getPropertyChangeListenerin interfaceChangeTracker
-
_persistence_setPropertyChangeListener
public void _persistence_setPropertyChangeListener(PropertyChangeListener listener)
Description copied from interface:ChangeTrackerPUBLIC: Set the PropertyChangeListener for the object.- Specified by:
_persistence_setPropertyChangeListenerin interfaceChangeTracker
-
_persistence_getFetchGroup
public FetchGroup _persistence_getFetchGroup()
Description copied from interface:FetchGroupTrackerReturn the fetch group being tracked- Specified by:
_persistence_getFetchGroupin interfaceFetchGroupTracker
-
_persistence_setFetchGroup
public void _persistence_setFetchGroup(FetchGroup group)
Description copied from interface:FetchGroupTrackerSet a fetch group to be tracked.- Specified by:
_persistence_setFetchGroupin interfaceFetchGroupTracker
-
_persistence_setShouldRefreshFetchGroup
public void _persistence_setShouldRefreshFetchGroup(boolean shouldRefreshFetchGroup)
Description copied from interface:FetchGroupTrackerSet true if the fetch group attributes should be refreshed.- Specified by:
_persistence_setShouldRefreshFetchGroupin interfaceFetchGroupTracker
-
_persistence_shouldRefreshFetchGroup
public boolean _persistence_shouldRefreshFetchGroup()
Description copied from interface:FetchGroupTrackerReturn true if the fetch group attributes should be refreshed.- Specified by:
_persistence_shouldRefreshFetchGroupin interfaceFetchGroupTracker
-
_persistence_isAttributeFetched
public boolean _persistence_isAttributeFetched(String attribute)
Return true if the attribute is in the fetch group being tracked.- Specified by:
_persistence_isAttributeFetchedin interfaceFetchGroupTracker- Parameters:
attribute- the attribute- Returns:
- true, if successful
-
_persistence_resetFetchGroup
public void _persistence_resetFetchGroup()
Reset all attributes of the tracked object to the un-fetched state with initial default values.- Specified by:
_persistence_resetFetchGroupin interfaceFetchGroupTracker
-
_persistence_getSession
public Session _persistence_getSession()
Description copied from interface:FetchGroupTrackerReturn the session for the object.- Specified by:
_persistence_getSessionin interfaceFetchGroupTracker
-
_persistence_setSession
public void _persistence_setSession(Session session)
Description copied from interface:FetchGroupTrackerSet true if the fetch group attributes should be refreshed- Specified by:
_persistence_setSessionin interfaceFetchGroupTracker
-
-