org.apache.ojb.broker
Class Identity

java.lang.Object
  extended by org.apache.ojb.broker.Identity
All Implemented Interfaces:
Serializable

public class Identity
extends Object
implements Serializable

Represents the identity of an object.
It's composed of:

To create Identity objects it's strongly recommended to use the IdentityFactory, because in future releases of OJB the Identity constructors will be no longer reachable or forbidden to use.

NOTE: An Identity object must be unique accross extents. Means all objects with the same top-level class need unique PK values.

Version:
$Id: Identity.java,v 1.1 2007-08-24 22:17:35 ewestfal Exp $
Author:
Thomas Mahler
See Also:
IdentityFactory, Serialized Form

Constructor Summary
protected Identity()
          For internal use only!
  Identity(Class realClass, Class topLevel, Object[] pkValues)
          For internal use only! Creates an Identity from a class and the objects primary key values.
  Identity(Class realClass, Class topLevel, Object[] pkValues, boolean isTransient)
          For internal use only!.
  Identity(Object objectToIdentitify, PersistenceBroker targetBroker)
          Constructor for internal use.
  Identity(Object objectToIdentitify, PersistenceBroker targetBroker, ClassDescriptor cld)
          Constructor for internal use.
 
Method Summary
protected  void checkForPrimaryKeys(Object realObject)
          OJB can handle only classes that declare at least one primary key attribute, this method checks this condition.
 boolean equals(Object obj)
          
static Identity fromByteArray(byte[] anArray)
          Deprecated.  
 Class getObjectsRealClass()
          Return the "real" class of the real subject.
 Class getObjectsTopLevelClass()
          Returns the top-level class of the real subject (base class, base interface denoted in the repository or objects real class if no top-level was found).
 Object[] getPrimaryKeyValues()
          Returns the primary key values of the real subject.
 int hashCode()
          
 boolean isTransient()
          Determines whether the identity is transient.
 byte[] serialize()
          Deprecated.  
 void setObjectsRealClass(Class objectsRealClass)
          Set the real class of the subject.
 String toString()
          return a String representation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Identity

protected Identity()
For internal use only!


Identity

public Identity(Class realClass,
                Class topLevel,
                Object[] pkValues,
                boolean isTransient)
For internal use only!. Creates an em from a class and the objects primary key values. used for the definition of proxies.
OJB user have to use IdentityFactory to create object identity.

Parameters:
realClass - the concrete class of the object, or null if not known.
topLevel - the highest persistence-capable class or interface (in the inheritance hierarchy) that the identified object is an instance of
pkValues - (unique across the extents !)
isTransient - If true

Identity

public Identity(Class realClass,
                Class topLevel,
                Object[] pkValues)
For internal use only! Creates an Identity from a class and the objects primary key values. used for the definition of proxies.
OJB user have to use IdentityFactory to create object identity.

Parameters:
realClass - the concrete class of the object, or null if not known.
topLevel - the highest persistence-capable class or interface (in the inheritance hierarchy) that the identified object is an instance of
pkValues - (unique across the extents !)

Identity

public Identity(Object objectToIdentitify,
                PersistenceBroker targetBroker)
Constructor for internal use. Use IdentityFactory to create an object identity.

Parameters:
objectToIdentitify - The object for which to create the identity
targetBroker - The persistence broker

Identity

public Identity(Object objectToIdentitify,
                PersistenceBroker targetBroker,
                ClassDescriptor cld)
Constructor for internal use. Use IdentityFactory to create an object identity.

Parameters:
objectToIdentitify - The object for which to create the identity
targetBroker - The persistence broker
cld - The class descriptor
Method Detail

fromByteArray

public static Identity fromByteArray(byte[] anArray)
                              throws PersistenceBrokerException
Deprecated. 

Factory method that returns an Identity object created from a serializated representation.

Parameters:
anArray - The serialized representation
Returns:
The identity
Throws:
PersistenceBrokerException
See Also:
#serialize}.

isTransient

public boolean isTransient()
Determines whether the identity is transient.

Returns:
true if the identity is transient

getObjectsTopLevelClass

public Class getObjectsTopLevelClass()
Returns the top-level class of the real subject (base class, base interface denoted in the repository or objects real class if no top-level was found).

Returns:
The top level class

getObjectsRealClass

public Class getObjectsRealClass()
Return the "real" class of the real subject.

Returns:
The real class

setObjectsRealClass

public void setObjectsRealClass(Class objectsRealClass)
Set the real class of the subject.

Parameters:
objectsRealClass - The real class

serialize

public byte[] serialize()
                 throws PersistenceBrokerException
Deprecated. 

Return the serialized form of this Identity.

Returns:
The serialized representation
Throws:
PersistenceBrokerException
See Also:
fromByteArray(byte[])

toString

public String toString()
return a String representation.

Overrides:
toString in class Object
Returns:
java.lang.String

checkForPrimaryKeys

protected void checkForPrimaryKeys(Object realObject)
                            throws ClassNotPersistenceCapableException
OJB can handle only classes that declare at least one primary key attribute, this method checks this condition.

Parameters:
realObject - The real object to check
Throws:
ClassNotPersistenceCapableException - thrown if no primary key is specified for the objects class

getPrimaryKeyValues

public Object[] getPrimaryKeyValues()
Returns the primary key values of the real subject.

Returns:
The pk values

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.