Module org.eclipse.persistence.core
Interface SerializedObjectPolicy
- All Superinterfaces:
Cloneable
,Serializable
- All Known Implementing Classes:
AbstractSerializedObjectPolicy
,SerializedObjectPolicyWrapper
SerializedObjectPolicy (SOP) could be set on a non-aggregate descriptor.
If SerializedObjectPolicy is specified Eclipselink writes out the whole entity object with its
privately owned (and nested privately owned) entities and element collections into an additional
(likely BLOB) field in the database.
If SerializedObjectPolicy is set on an entity then SerializedObjectPolicies with the same field are set
on all inheriting entities.
The goal is to make reads from the database faster.
The draw back is slower writes into the database.
So SerializedObjectPolicy may make sense for read-only / read-mostly application
for Entity, which always loads all its dependent entities and / or ElementCollections.
To use SerializedObjectPolicy, ObjectLevelReadQuery should set a boolean flag
- Since:
- EclipseLink 2.5.1
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Lists the database fields that should be read by the query using the policy, in case all inherited objects are read using outer joining.get owning descriptorgetField()
get the field that stores sopObject in the database (sopField)getObjectFromRow
(AbstractRecord databaseRow, AbstractSession session, ObjectLevelReadQuery query) Deserialize the object from the value corresponding to the policy field, nullify that value, set the object into the row using setSopObject, also return it.Lists the database fields that should be read by the query using the policy.void
initialize
(AbstractSession session) initialize the policyvoid
initializeField
(AbstractSession session) unless the field is already initialized by parent descriptor, add the field to the owning descriptor and set field's typeinstantiate policy for child descriptorvoid
postInitialize
(AbstractSession session) postinitialize the policy: determine which mappings are included, which fields should be selectedvoid
putObjectIntoRow
(AbstractRecord databaseRow, Object object, AbstractSession session) Serialize the object and put the result into the row as a value corresponding to the policy fieldvoid
setDescriptor
(ClassDescriptor descriptor) set owning descriptorvoid
setField
(DatabaseField field) set the field that stores sopObject in the database (sopField)
-
Method Details
-
getDescriptor
ClassDescriptor getDescriptor()get owning descriptor -
setDescriptor
set owning descriptor -
getField
DatabaseField getField()get the field that stores sopObject in the database (sopField) -
setField
set the field that stores sopObject in the database (sopField) -
clone
SerializedObjectPolicy clone() -
instantiateChild
SerializedObjectPolicy instantiateChild()instantiate policy for child descriptor -
initializeField
unless the field is already initialized by parent descriptor, add the field to the owning descriptor and set field's type -
initialize
initialize the policy -
postInitialize
postinitialize the policy: determine which mappings are included, which fields should be selected -
getSelectionFields
List<DatabaseField> getSelectionFields()Lists the database fields that should be read by the query using the policy. To allow recovery in case of null or invalid sopObject, then this method should return all the fields define by descriptor (descriptor.getFields()). -
getAllSelectionFields
List<DatabaseField> getAllSelectionFields()Lists the database fields that should be read by the query using the policy, in case all inherited objects are read using outer joining. To allow recovery in case of null or invalid sopObject, then this method should return all the fields define by descriptor (descriptor.getAllFields()). -
putObjectIntoRow
Serialize the object and put the result into the row as a value corresponding to the policy field -
getObjectFromRow
Object getObjectFromRow(AbstractRecord databaseRow, AbstractSession session, ObjectLevelReadQuery query) Deserialize the object from the value corresponding to the policy field, nullify that value, set the object into the row using setSopObject, also return it. If the object is null or invalid, behaviour depend on whether the policy allows the query to recover or not (see comments to getFieldsToSelect and getAllFieldsToSelect methods): if recovery is possible then the method should return null, otherwise throw QueryException (query is a parameter of this method only because it's required by QueryException).
-