Package org.apache.cayenne
Class ObjectId
java.lang.Object
org.apache.cayenne.ObjectId
- All Implemented Interfaces:
- Serializable
public class ObjectId extends Object implements Serializable
A portable global identifier for persistent objects. ObjectId can be
 temporary (used for transient or new uncommitted objects) or permanent (used
 for objects that have been already stored in DB). A temporary ObjectId stores
 object entity name and a pseudo-unique binary key; permanent id stores a map
 of values from an external persistent store (aka "primary key").
- See Also:
- Serialized Form
- 
Field SummaryFields Modifier and Type Field Description protected StringentityNameprotected byte[]keyprotected Map<String,Object>objectIdKeysprotected Map<String,Object>replacementIdMap
- 
Constructor SummaryConstructors Constructor Description ObjectId(String entityName)Creates a TEMPORARY ObjectId.ObjectId(String entityName, byte[] key)Creates a TEMPORARY id with a specified entity name and a binary key.ObjectId(String entityName, String key, int value)Creates a portable permanent ObjectId.ObjectId(String entityName, String key, Object value)Creates a portable permanent ObjectId.ObjectId(String entityName, Map<String,?> idMap)Creates a portable permanent ObjectId as a compound primary key.
- 
Method SummaryModifier and Type Method Description ObjectIdcreateReplacementId()Creates and returns a replacement ObjectId.booleanequals(Object object)StringgetEntityName()Map<String,Object>getIdSnapshot()Returns an unmodifiable Map of persistent id values, essentially a primary key map.byte[]getKey()Get the binary temporary object id.Map<String,Object>getReplacementIdMap()Returns a non-null mutable map that can be used to append replacement id values.inthashCode()booleanisReplacementIdAttached()Returns true if there is full or partial replacement id attached to this id.booleanisTemporary()Is this is temporary object id (used for objects which are not yet persisted to the data store).StringtoString()A standard toString method used for debugging.
- 
Field Details- 
entityName
- 
objectIdKeys
- 
keyprotected byte[] key
- 
replacementIdMap
 
- 
- 
Constructor Details- 
ObjectIdCreates a TEMPORARY ObjectId. Assigns a generated unique key.- Since:
- 1.2
 
- 
ObjectIdCreates a TEMPORARY id with a specified entity name and a binary key. It is a caller responsibility to provide a globally unique binary key.- Since:
- 1.2
 
- 
ObjectIdCreates a portable permanent ObjectId.- Parameters:
- entityName- The entity name which this object id is for
- key- A key describing this object id, usually the attribute name for the primary key
- value- The unique value for this object id
- Since:
- 1.2
 
- 
ObjectIdCreates a portable permanent ObjectId.- Parameters:
- entityName- The entity name which this object id is for
- key- A key describing this object id, usually the attribute name for the primary key
- value- The unique value for this object id
- Since:
- 1.2
 
- 
ObjectIdCreates a portable permanent ObjectId as a compound primary key.- Parameters:
- entityName- The entity name which this object id is for
- idMap- Keys are usually the attribute names for each part of the primary key. Values are unique when taken as a whole.
- Since:
- 1.2
 
 
- 
- 
Method Details- 
isTemporarypublic boolean isTemporary()Is this is temporary object id (used for objects which are not yet persisted to the data store).
- 
getEntityName- Since:
- 1.2
 
- 
getKeypublic byte[] getKey()Get the binary temporary object id. Null if this object id is permanent (persisted to the data store).
- 
getIdSnapshotReturns an unmodifiable Map of persistent id values, essentially a primary key map. For temporary id returns replacement id, if it was already created. Otherwise returns an empty map.
- 
equals
- 
hashCodepublic int hashCode()
- 
getReplacementIdMapReturns a non-null mutable map that can be used to append replacement id values. This allows to incrementally build a replacement GlobalID.- Since:
- 1.2
 
- 
createReplacementIdCreates and returns a replacement ObjectId. No validation of ID is done.- Since:
- 1.2
 
- 
isReplacementIdAttachedpublic boolean isReplacementIdAttached()Returns true if there is full or partial replacement id attached to this id. This method is preferrable to "!getReplacementIdMap().isEmpty()" as it avoids unneeded replacement id map creation.
- 
toStringA standard toString method used for debugging. It is guaranteed to produce the same string if two ObjectIds are equal.
 
-