Package org.apache.cayenne
Class HybridDataObject
- java.lang.Object
-
- org.apache.cayenne.PersistentObject
-
- org.apache.cayenne.BaseDataObject
-
- org.apache.cayenne.HybridDataObject
-
- All Implemented Interfaces:
Serializable,DataObject,Persistent,Validating
public class HybridDataObject extends BaseDataObject
This data object likeCayenneDataObjectusesMapto store generic attributes, only difference is that this Map will be created lazily at first write, thus reducing memory penalty if possible.This class can be used as superclass for objects that have attributes created at runtime. If generic runtime attributes will be used always it may be a good idea to use
CayenneDataObjectinstead. If you don't create attributes at runtime it is better to useBaseDataObjectclass.Map creation is not thread safe, as DataObject in general not thread safe by it's own.
- Since:
- 4.1
- See Also:
BaseDataObject,CayenneDataObject, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Object>values-
Fields inherited from class org.apache.cayenne.BaseDataObject
snapshotVersion
-
Fields inherited from class org.apache.cayenne.PersistentObject
objectContext, objectId, persistenceState
-
Fields inherited from interface org.apache.cayenne.DataObject
DEFAULT_VERSION
-
-
Constructor Summary
Constructors Constructor Description HybridDataObject()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappendProperties(StringBuffer buffer)ObjectreadPropertyDirectly(String propName)Returns mapped property value as curently stored in the DataObject.protected voidreadState(ObjectInputStream in)voidwritePropertyDirectly(String propName, Object val)Modifies a value of a named property without altering the object state in any way, and without triggering any database operations.protected voidwriteState(ObjectOutputStream out)-
Methods inherited from class org.apache.cayenne.BaseDataObject
addToManyTarget, beforePropertyRead, beforePropertyWrite, getSnapshotVersion, readNestedProperty, readProperty, readSerialized, removeToManyTarget, setObjectContext, setPersistenceState, setReverseRelationship, setSnapshotVersion, setToManyTarget, setToOneTarget, toString, toStringBuffer, unsetReverseRelationship, validateForDelete, validateForInsert, validateForSave, validateForUpdate, willConnect, writeProperty, writeSerialized
-
Methods inherited from class org.apache.cayenne.PersistentObject
getMapKey, getObjectContext, getObjectId, getPersistenceState, setObjectId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.cayenne.Persistent
getObjectContext, getObjectId, getPersistenceState, setObjectId
-
-
-
-
Method Detail
-
readPropertyDirectly
public Object readPropertyDirectly(String propName)
Description copied from interface:DataObjectReturns mapped property value as curently stored in the DataObject. Returned value maybe a fault or a real value. This method will not attempt to resolve faults, or to read unmapped properties.- Specified by:
readPropertyDirectlyin interfaceDataObject- Overrides:
readPropertyDirectlyin classBaseDataObject
-
writePropertyDirectly
public void writePropertyDirectly(String propName, Object val)
Description copied from interface:DataObjectModifies a value of a named property without altering the object state in any way, and without triggering any database operations. This method is intended mostly for internal use by Cayenne framework, and shouldn't be called from the application code.- Specified by:
writePropertyDirectlyin interfaceDataObject- Overrides:
writePropertyDirectlyin classBaseDataObject
-
appendProperties
protected void appendProperties(StringBuffer buffer)
- Overrides:
appendPropertiesin classBaseDataObject
-
readState
protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException
- Overrides:
readStatein classBaseDataObject- Throws:
IOExceptionClassNotFoundException
-
writeState
protected void writeState(ObjectOutputStream out) throws IOException
- Overrides:
writeStatein classBaseDataObject- Throws:
IOException
-
-