Package org.apache.cayenne

# Class CayenneDataObject

java.lang.Object
org.apache.cayenne.PersistentObject
org.apache.cayenne.BaseDataObject
org.apache.cayenne.CayenneDataObject

All Implemented Interfaces:
  `Serializable`, `DataObject`, `Persistent`, `Validating`

public class CayenneDataObject extends BaseDataObject
Implementation of `DataObject` that uses `Map` to store object fields.

This implementation was pre 4.1 default.

Since 4.1 it is recommended to use `BaseDataObject` as superclass (and it is actually default now), as it has better performance and lower memory consumption (much lower for small objects).

You may need to use this class only if you have some generic attributes created at runtime (also consider `HybridDataObject` in this case) or if any compatibility issues arise.

See Also:
  - `BaseDataObject`
  - `HybridDataObject`
  - 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
  `CayenneDataObject()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `appendProperties(StringBuffer buffer)`
  `static String`
  `makePath(String... pathParts)`
  Deprecated.
  since 4.1, use `Cayenne.makePath(String...)` instead
  `Object`
  `readPropertyDirectly(String propName)`
  Returns mapped property value as curently stored in the DataObject.
  `protected void`
  `readState(ObjectInputStream in)`
  `void`
  `setPersistenceState(int persistenceState)`
  `void`
  `writePropertyDirectly(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 void`
  `writeState(ObjectOutputStream out)`

  ### Methods inherited from class org.apache.cayenne.BaseDataObject

  `addToManyTarget, beforePropertyRead, beforePropertyWrite, getSnapshotVersion, readNestedProperty, readProperty, readSerialized, removeToManyTarget, setObjectContext, 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`

- ## Field Details

  - ### values

    protected Map<String,Object> values

- ## Constructor Details

  - ### CayenneDataObject

    public CayenneDataObject()

- ## Method Details

  - ### setPersistenceState

    public void setPersistenceState(int persistenceState)
    Specified by:
      `setPersistenceState` in interface `Persistent`
    Overrides:
      `setPersistenceState` in class `BaseDataObject`

  - ### readPropertyDirectly

    public Object readPropertyDirectly(String propName)
    Description copied from interface: `DataObject`
    Returns 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:
      `readPropertyDirectly` in interface `DataObject`
    Overrides:
      `readPropertyDirectly` in class `BaseDataObject`

  - ### writePropertyDirectly

    public void writePropertyDirectly(String propName, Object val)
    Description copied from interface: `DataObject`
    Modifies 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:
      `writePropertyDirectly` in interface `DataObject`
    Overrides:
      `writePropertyDirectly` in class `BaseDataObject`

  - ### appendProperties

    protected void appendProperties(StringBuffer buffer)
    Overrides:
      `appendProperties` in class `BaseDataObject`

  - ### readState

    protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException
    Overrides:
      `readState` in class `BaseDataObject`
    Throws:
      `IOException`
      `ClassNotFoundException`

  - ### writeState

    protected void writeState(ObjectOutputStream out) throws IOException
    Overrides:
      `writeState` in class `BaseDataObject`
    Throws:
      `IOException`

  - ### makePath

    @Deprecated public static String makePath(String... pathParts)
    Deprecated.
    since 4.1, use `Cayenne.makePath(String...)` instead
    Convenience method to invoke `Cayenne.makePath(String...)` from within a DataObject subclass to create a dotted path using the generated string constants for attributes and relationships.
    Since:
      3.1
    See Also:
      - `Cayenne.makePath(String...)`