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

## org.objectstyle.cayenne
Class ObjectId

    java.lang.Object
      org.objectstyle.cayenne.ObjectId

All Implemented Interfaces:
  java.io.Serializable

Direct Known Subclasses:
  TempObjectId

    public class ObjectId

extends java.lang.Object
implements java.io.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 java.lang.String` | `entityName`
`protected byte[]` | `key`
`protected java.util.Map` | `objectIdKeys`
`protected java.util.Map` | `replacementIdMap`

Constructor Summary
`ObjectId(java.lang.Class objectClass)` Deprecated. since 1.2, as new portable ObjectIds can't store Java Class and store entity name instead. This constructor relies on default CayenneModeler naming convention to figure out entity name from class name. This may not work if the classes where mapped differently.
`ObjectId(java.lang.Class objectClass, java.util.Map idKeys)` Deprecated. since 1.2, as new portable ObjectIds can't store Java Class and store entity name instead. This constructor relies on default CayenneModeler naming convention to figure out entity name from class name. This may not work if the classes where mapped differently.
`ObjectId(java.lang.Class objectClass, java.lang.String keyName, int id)` Deprecated. since 1.2, as new portable ObjectIds can't store Java Class and store entity name instead. This constructor relies on default CayenneModeler naming convention to figure out entity name from class name. This may not work if the classes where mapped differently.
`ObjectId(java.lang.Class objectClass, java.lang.String keyName, java.lang.Object id)` Deprecated. since 1.2, as new portable ObjectIds can't store Java Class and store entity name instead. This constructor relies on default CayenneModeler naming convention to figure out entity name from class name. This may not work if the classes where mapped differently.
`ObjectId(java.lang.String entityName)` Creates a TEMPORARY ObjectId.
`ObjectId(java.lang.String entityName, byte[] key)` Creates a TEMPORARY id with a specified entity name and a binary key.
`ObjectId(java.lang.String entityName, java.util.Map idMap)` Creates a portable permanent ObjectId.
`ObjectId(java.lang.String entityName, java.lang.String key, int value)` Creates a portable permanent ObjectId.
`ObjectId(java.lang.String entityName, java.lang.String key, java.lang.Object value)` Creates a portable permanent ObjectId.

Method Summary
`ObjectId` | `createReplacementId()` Creates and returns a replacement ObjectId.
`boolean` | `equals(java.lang.Object object)`
`java.lang.String` | `getEntityName()`
`java.util.Map` | `getIdSnapshot()` Returns an unmodifiable Map of persistent id values, essentailly a primary key map.
`byte[]` | `getKey()`
`ObjectId` | `getReplacementId()` Deprecated. Since 1.2 replacement id is built by appending to replacementIdMap.
`java.util.Map` | `getReplacementIdMap()` Returns a non-null mutable map that can be used to append replacement id values.
`java.lang.Object` | `getValueForAttribute(java.lang.String attrName)` Deprecated. since 1.2. This method is redundant. Use `getIdSnapshot().get(attrName)` instead.
`int` | `hashCode()`
`boolean` | `isReplacementIdAttached()` Returns true if there is full or partial replacement id attached to this id.
`boolean` | `isTemporary()`
`protected void` | `setIdKeys(java.util.Map idKeys)` Deprecated. since 1.2
`void` | `setReplacementId(ObjectId replacementId)` Deprecated. Since 1.2 replacement id is built by appending to replacementIdMap.
`java.lang.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 java.lang.String entityName

### objectIdKeys

    protected java.util.Map objectIdKeys

### key

    protected byte[] key

### replacementIdMap

    protected java.util.Map replacementIdMap

Constructor Detail

### ObjectId

    public ObjectId(java.lang.String entityName)

  Creates a TEMPORARY ObjectId. Assignes a generated unique key.

  Since:
    1.2

### ObjectId

    public ObjectId(java.lang.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(java.lang.String entityName,
                    java.lang.String key,
                    int value)

  Creates a portable permanent ObjectId.

  Since:
    1.2

### ObjectId

    public ObjectId(java.lang.String entityName,
                    java.lang.String key,
                    java.lang.Object value)

  Creates a portable permanent ObjectId.

  Since:
    1.2

### ObjectId

    public ObjectId(java.lang.String entityName,
                    java.util.Map idMap)

  Creates a portable permanent ObjectId.

  Since:
    1.2

### ObjectId

    public ObjectId(java.lang.Class objectClass)

  Deprecated. since 1.2, as new portable ObjectIds can't store Java Class and store entity name instead. This constructor relies on default CayenneModeler naming convention to figure out entity name from class name. This may not work if the classes where mapped differently.

### ObjectId

    public ObjectId(java.lang.Class objectClass,
                    java.lang.String keyName,
                    int id)

  Deprecated. since 1.2, as new portable ObjectIds can't store Java Class and store entity name instead. This constructor relies on default CayenneModeler naming convention to figure out entity name from class name. This may not work if the classes where mapped differently.

### ObjectId

    public ObjectId(java.lang.Class objectClass,
                    java.lang.String keyName,
                    java.lang.Object id)

  Deprecated. since 1.2, as new portable ObjectIds can't store Java Class and store entity name instead. This constructor relies on default CayenneModeler naming convention to figure out entity name from class name. This may not work if the classes where mapped differently.

### ObjectId

    public ObjectId(java.lang.Class objectClass,
                    java.util.Map idKeys)

  Deprecated. since 1.2, as new portable ObjectIds can't store Java Class and store entity name instead. This constructor relies on default CayenneModeler naming convention to figure out entity name from class name. This may not work if the classes where mapped differently.

Method Detail

### isTemporary

    public boolean isTemporary()

### getEntityName

    public java.lang.String getEntityName()

  Since:
    1.2

### getKey

    public byte[] getKey()

### setIdKeys

    protected void setIdKeys(java.util.Map idKeys)

  Deprecated. since 1.2

### getIdSnapshot

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

### getValueForAttribute

    public java.lang.Object getValueForAttribute(java.lang.String attrName)

  Deprecated. since 1.2. This method is redundant. Use `getIdSnapshot().get(attrName)` instead.

  Returns a value of id attribute identified by the name of DbAttribute.

### equals

    public boolean equals(java.lang.Object object)

  Overrides:
    `equals` in class `java.lang.Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `java.lang.Object`

### getReplacementId

    public ObjectId getReplacementId()

  Deprecated. Since 1.2 replacement id is built by appending to replacementIdMap.

  Returns a replacement ObjectId associated with this id. Replacement ObjectId is either a permananent ObjectId for an uncommitted object or a new id for object whose id depends on its relationships.

### setReplacementId

    public void setReplacementId(ObjectId replacementId)

  Deprecated. Since 1.2 replacement id is built by appending to replacementIdMap.

  Initializes a replacement ObjectId.

### getReplacementIdMap

    public java.util.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 java.lang.String toString()

  A standard toString method used for debugging.

  Overrides:
    `toString` in class `java.lang.Object`

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

Copyright © 2001-2006 ObjectStyle.org All Rights Reserved.