Package org.eclipse.persistence.dynamic
Interface DynamicEntity
-
public interface DynamicEntityDynamicEntityis the public interface for dealing with dynamic persistent objects.The purpose of dynamic persistent objects is to enable (simple) data access when only mapping information is available
and no concrete Java model is present (specifically, no .class files .)Applications using
DynamicEntity's can access the persistent state using property names which correspond
to the mapped attributes in the underlying EclipseLink descriptors. For properties mapped to containers (Collection,
Map, etc.), the property is retrieved then the resulting container can be manipulated.... DynamicEntity de = ...; // retrieve from database Collection<String> myListOfGroups = de.<Collection<String>>get("myListOfGroups"); if (!myListOfGroups.isEmpty()) { myListOfGroups.add("FabFour"); }To discover meta-data about a DynamicEntity's properties, see theDynamicHelperclass- Author:
- dclarke, mnorman
- Since:
- EclipseLink 1.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> Tget(java.lang.String propertyName)Return the persistence value for the given property as the specified type.booleanisSet(java.lang.String propertyName)Discover if a property has a persistent valueDynamicEntityset(java.lang.String propertyName, java.lang.Object value)Set the persistence value for the given property to the specified value
-
-
-
Method Detail
-
get
<T> T get(java.lang.String propertyName) throws DynamicException
Return the persistence value for the given property as the specified type. In the case of relationships, this call will populate lazy-loaded relationships- 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
-
set
DynamicEntity set(java.lang.String propertyName, java.lang.Object value) throws DynamicException
Set the persistence value for the given property to the specified value- 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
-
isSet
boolean isSet(java.lang.String propertyName) throws DynamicExceptionDiscover if a property has a persistent value- 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
-
-