org.apache.cayenne

## Class PersistentObject

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

- All Implemented Interfaces:
    Serializable, Persistent
  Direct Known Subclasses:
    BaseDataObject

      public abstract class PersistentObject
      extends Object
      implements Persistent

  A convenience base superclass for concrete Persistent objects. Provides implementation of properties declared in Persistent interface.

  # POJO Note

  If having PersistentObject as a superclass presents a problem in an application, source code of this class can be copied verbatim to a custom class generation template. Desired superclass can be set in CayenneModeler.

  Since:
    1.2
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ObjectContext` | `objectContext`
    `protected ObjectId` | `objectId`
    `protected int` | `persistenceState`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PersistentObject()` Creates a new transient object.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Object` | `getMapKey(String relationshipName, Object value)` Returns a map key for a given to-many map relationship and a target object.
    `ObjectContext` | `getObjectContext()`
    `ObjectId` | `getObjectId()`
    `int` | `getPersistenceState()`
    `void` | `setObjectContext(ObjectContext objectContext)`
    `void` | `setObjectId(ObjectId objectId)`
    `void` | `setPersistenceState(int persistenceState)`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

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

- - ### Field Detail

    - #### objectId

          protected ObjectId objectId

    - #### persistenceState

          protected int persistenceState

    - #### objectContext

          protected transient ObjectContext objectContext

  - ### Constructor Detail

    - #### PersistentObject

          public PersistentObject()

      Creates a new transient object.

  - ### Method Detail

    - #### getPersistenceState

          public int getPersistenceState()

      Specified by:
        `getPersistenceState` in interface `Persistent`

    - #### setPersistenceState

          public void setPersistenceState(int persistenceState)

      Specified by:
        `setPersistenceState` in interface `Persistent`

    - #### getObjectContext

          public ObjectContext getObjectContext()

      Specified by:
        `getObjectContext` in interface `Persistent`

    - #### setObjectContext

          public void setObjectContext(ObjectContext objectContext)

      Specified by:
        `setObjectContext` in interface `Persistent`

    - #### getObjectId

          public ObjectId getObjectId()

      Specified by:
        `getObjectId` in interface `Persistent`

    - #### setObjectId

          public void setObjectId(ObjectId objectId)

      Specified by:
        `setObjectId` in interface `Persistent`

    - #### getMapKey

          protected Object getMapKey(String relationshipName,
                                     Object value)

      Returns a map key for a given to-many map relationship and a target object.
      Since:
        3.0

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2001–2021 Apache Cayenne. All rights reserved.