Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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").

Author:
  Andrus Adamchik
See Also:
  Serialized Form

Field Summary
`protected String` | `entityName`
`protected byte[]` | `key`
`protected Map` | `objectIdKeys`
`protected Map` | `replacementIdMap`

Constructor Summary
`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, Map idMap)` Creates a portable permanent ObjectId.
`ObjectId(String entityName, String key, int value)` Creates a portable permanent ObjectId.
`ObjectId(String entityName, String key, Object value)` Creates a portable permanent ObjectId.

Method Summary
`ObjectId` | `createReplacementId()` Creates and returns a replacement ObjectId.
`boolean` | `equals(Object object)`
`String` | `getEntityName()`
`Map` | `getIdSnapshot()` Returns an unmodifiable Map of persistent id values, essentailly a primary key map.
`byte[]` | `getKey()`
`Map` | `getReplacementIdMap()` Returns a non-null mutable map that can be used to append replacement id values.
`int` | `hashCode()`
`boolean` | `isReplacementIdAttached()` Returns true if there is full or partial replacement id attached to this id.
`boolean` | `isTemporary()`
`String` | `toString()` A standard toString method used for debugging.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### entityName

    protected String entityName

### objectIdKeys

    protected Map objectIdKeys

### key

    protected byte[] key

### replacementIdMap

    protected Map replacementIdMap

Constructor Detail

### ObjectId

    public ObjectId(String entityName)

  Creates a TEMPORARY ObjectId. Assignes a generated unique key.

  Since:
    1.2

### ObjectId

    public ObjectId(String entityName,
                    byte[] key)

  Creates 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

### ObjectId

    public ObjectId(String entityName,
                    String key,
                    int value)

  Creates a portable permanent ObjectId.

  Since:
    1.2

### ObjectId

    public ObjectId(String entityName,
                    String key,
                    Object value)

  Creates a portable permanent ObjectId.

  Since:
    1.2

### ObjectId

    public ObjectId(String entityName,
                    Map idMap)

  Creates a portable permanent ObjectId.

  Since:
    1.2

Method Detail

### isTemporary

    public boolean isTemporary()

### getEntityName

    public String getEntityName()

  Since:
    1.2

### getKey

    public byte[] getKey()

### getIdSnapshot

    public Map getIdSnapshot()

  Returns an unmodifiable Map of persistent id values, essentailly a primary key map. For temporary id returns replacement id, if it was already created. Otherwise returns an empty map.

### equals

    public boolean equals(Object object)

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### getReplacementIdMap

    public Map getReplacementIdMap()

  Returns 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

### createReplacementId

    public ObjectId createReplacementId()

  Creates and returns a replacement ObjectId. No validation of ID is done.

  Since:
    1.2

### isReplacementIdAttached

    public 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.

### toString

    public String toString()

  A standard toString method used for debugging. It is guaranteed to produce the same string if two ObjectIds are equal.

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2007 Apache Cayenne. All Rights Reserved.