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
DynamicTypeImpl
wraps the underlying EclipseLink relational-descriptor and theDynamicPropertiesManager
wraps 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 class
DynamicEntityImpl.PropertyWrapper
-
Field Summary
Fields Modifier and Type Field Description protected CacheKey
cacheKey
protected Map<String,DynamicEntityImpl.PropertyWrapper>
propertiesMap
-
Constructor Summary
Constructors Constructor Description DynamicEntityImpl()
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 DynamicPropertiesManager
fetchPropertiesManager()
Fetch properties manager.<T> T
get(String propertyName)
Return the persistence value for the given property as the specified type.Map<String,DynamicEntityImpl.PropertyWrapper>
getPropertiesMap()
Gets the properties map.DynamicTypeImpl
getType()
Gets internal impl class ofDynamicType
.boolean
isSet(String propertyName)
Discover if a property has a persistent valueprotected void
postConstruct()
Post construct.DynamicEntity
set(String propertyName, Object value)
Set the persistence value for the given property to the specified valueDynamicEntity
set(String propertyName, Object value, boolean firePropertyChange)
Sets the.String
toString()
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:DynamicEntity
Return 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:
get
in interfaceDynamicEntity
- Type Parameters:
T
- generic type of the property (if not provided, assume Object). If the property cannot be cast to the specific type, aDynamicException
will be thrown.- Parameters:
propertyName
- the name of a mapped property If the property cannot be found, aDynamicException
will 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:DynamicEntity
Discover if a property has a persistent value- Specified by:
isSet
in interfaceDynamicEntity
- Parameters:
propertyName
- the name of a mapped property If the property cannot be found, aDynamicException
will 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:DynamicEntity
Set the persistence value for the given property to the specified value- Specified by:
set
in interfaceDynamicEntity
- Parameters:
propertyName
- the name of a mapped property If the property cannot be found, aDynamicException
will 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_getId
in interfacePersistenceEntity
-
_persistence_setId
public void _persistence_setId(Object pk)
- Specified by:
_persistence_setId
in interfacePersistenceEntity
-
_persistence_getCacheKey
public CacheKey _persistence_getCacheKey()
- Specified by:
_persistence_getCacheKey
in interfacePersistenceEntity
-
_persistence_setCacheKey
public void _persistence_setCacheKey(CacheKey cacheKey)
- Specified by:
_persistence_setCacheKey
in interfacePersistenceEntity
-
_persistence_getPropertyChangeListener
public PropertyChangeListener _persistence_getPropertyChangeListener()
Description copied from interface:ChangeTracker
PUBLIC: Return the PropertyChangeListener for the object.- Specified by:
_persistence_getPropertyChangeListener
in interfaceChangeTracker
-
_persistence_setPropertyChangeListener
public void _persistence_setPropertyChangeListener(PropertyChangeListener listener)
Description copied from interface:ChangeTracker
PUBLIC: Set the PropertyChangeListener for the object.- Specified by:
_persistence_setPropertyChangeListener
in interfaceChangeTracker
-
_persistence_getFetchGroup
public FetchGroup _persistence_getFetchGroup()
Description copied from interface:FetchGroupTracker
Return the fetch group being tracked- Specified by:
_persistence_getFetchGroup
in interfaceFetchGroupTracker
-
_persistence_setFetchGroup
public void _persistence_setFetchGroup(FetchGroup group)
Description copied from interface:FetchGroupTracker
Set a fetch group to be tracked.- Specified by:
_persistence_setFetchGroup
in interfaceFetchGroupTracker
-
_persistence_setShouldRefreshFetchGroup
public void _persistence_setShouldRefreshFetchGroup(boolean shouldRefreshFetchGroup)
Description copied from interface:FetchGroupTracker
Set true if the fetch group attributes should be refreshed.- Specified by:
_persistence_setShouldRefreshFetchGroup
in interfaceFetchGroupTracker
-
_persistence_shouldRefreshFetchGroup
public boolean _persistence_shouldRefreshFetchGroup()
Description copied from interface:FetchGroupTracker
Return true if the fetch group attributes should be refreshed.- Specified by:
_persistence_shouldRefreshFetchGroup
in interfaceFetchGroupTracker
-
_persistence_isAttributeFetched
public boolean _persistence_isAttributeFetched(String attribute)
Return true if the attribute is in the fetch group being tracked.- Specified by:
_persistence_isAttributeFetched
in 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_resetFetchGroup
in interfaceFetchGroupTracker
-
_persistence_getSession
public Session _persistence_getSession()
Description copied from interface:FetchGroupTracker
Return the session for the object.- Specified by:
_persistence_getSession
in interfaceFetchGroupTracker
-
_persistence_setSession
public void _persistence_setSession(Session session)
Description copied from interface:FetchGroupTracker
Set true if the fetch group attributes should be refreshed- Specified by:
_persistence_setSession
in interfaceFetchGroupTracker
-
-