# Class HybridPersistentObject

java.lang.Object
org.apache.cayenne.PersistentObject
org.apache.cayenne.HybridPersistentObject

All Implemented Interfaces:
  `Serializable, Persistent, Validating`

public class HybridPersistentObject extends PersistentObject
This data object like `GenericPersistentObject` uses `Map` to 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 always be used it may be a good idea to use `GenericPersistentObject` instead. If you don't create attributes at runtime it is better to use `PersistentObject` class.

Map creation is not thread safe, as PersistentObject in general not thread safe by its own.

Since:
  4.1, 5.0, renamed from HybridDataObject
See Also:
  - `PersistentObject`
  - `GenericPersistentObject`
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected Map<String,Object>`
  `values`

  ### Fields inherited from class PersistentObject

  `objectContext, objectId, persistenceState, snapshotVersion`

  ### Fields inherited from interface Persistent

  `DEFAULT_VERSION`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `HybridPersistentObject()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `appendProperties(StringBuffer buffer)`
  `Object`
  `readPropertyDirectly(String propName)`
  Returns mapped property value as currently stored in the Persistent object.
  `protected void`
  `readState(ObjectInputStream in)`
  `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 PersistentObject

  `addToManyTarget, beforePropertyRead, beforePropertyWrite, getMapKey, getObjectContext, getObjectId, getPersistenceState, getSnapshotVersion, readNestedProperty, readNestedProperty, readProperty, readSerialized, removeToManyTarget, setObjectContext, setObjectId, setPersistenceState, setReverseRelationship, setSnapshotVersion, setToManyTarget, setToOneTarget, toString, toStringBuffer, unsetReverseRelationship, validateForDelete, validateForInsert, validateForSave, validateForUpdate, willConnect, writeProperty, writeSerialized`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### values

    protected Map<String,Object> values

- ## Constructor Details

  - ### HybridPersistentObject

    public HybridPersistentObject()

- ## Method Details

  - ### readPropertyDirectly

    public Object readPropertyDirectly(String propName)
    Description copied from interface: `Persistent`
    Returns mapped property value as currently stored in the Persistent object. 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 `Persistent`
    Overrides:
      `readPropertyDirectly` in class `PersistentObject`

  - ### writePropertyDirectly

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

  - ### appendProperties

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

  - ### readState

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

  - ### writeState

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