org.apache.ojb.broker
Interface IdentityFactory

All Known Implementing Classes:
IdentityFactoryImpl

public interface IdentityFactory

Builds Identity objects to identify persistence capable objects within OJB. In many cases the primary key (based on metadata declaration) of an object is known and the whole object should be materialized (e.g. findByPrimaryKey(...) calls). This class make available a bunch of methods help to create Identity objects based on

NOTE:
It is possible to create transient Identity objects for transient, "new created" persistence capable objects. But keep in mind that this transient Identity object is only valid till the persistence capable object was written to datastore. After this the Identity have to be renewed by calling IdentityFactory.buildIdentity(...) again (then the transient Identity will be replaced by the persistent Identity).

Version:
$Id: IdentityFactory.java 365231 2005-12-21 22:22:08Z tomdz $

Method Summary
 Identity buildIdentity(java.lang.Class realClass, java.lang.Class topLevelClass, java.lang.Object[] pkValues)
          Create a new Identity object based on given arguments - NOTE: There will be no check to resolve the order of the PK values.
 Identity buildIdentity(java.lang.Class realClass, java.lang.Class topLevelClass, java.lang.String[] pkFieldName, java.lang.Object[] pkValues)
          Build a unique Identity for the given primary key values (composite PK's) of a persistence capable object.
 Identity buildIdentity(ClassDescriptor cld, java.lang.Object obj)
          Build a unique Identity for the given persistence capable object.
 Identity buildIdentity(java.lang.Class realClass, java.lang.Object pkValue)
          Convenience method for persistent objects with single primary key.
 Identity buildIdentity(java.lang.Class realClass, java.lang.String[] pkFieldName, java.lang.Object[] pkValues)
          Convenience shortcut method for buildIdentity(java.lang.Class, java.lang.Class, java.lang.String[], java.lang.Object[]).
 Identity buildIdentity(java.lang.Object obj)
          Build a unique Identity for the given persistence capable object.
 

Method Detail

buildIdentity

Identity buildIdentity(java.lang.Object obj)
Build a unique Identity for the given persistence capable object.

Parameters:
obj - The object to build the Identity for
Returns:
The new Identity object

buildIdentity

Identity buildIdentity(ClassDescriptor cld,
                       java.lang.Object obj)
Build a unique Identity for the given persistence capable object.

Parameters:
cld - The ClassDescriptor of the object
obj - The object to build the Identity for
Returns:
The new Identity object.

buildIdentity

Identity buildIdentity(java.lang.Class realClass,
                       java.lang.Class topLevelClass,
                       java.lang.String[] pkFieldName,
                       java.lang.Object[] pkValues)
Build a unique Identity for the given primary key values (composite PK's) of a persistence capable object.

Parameters:
realClass - The class of the associated object
topLevelClass - The top-level class of the associated object
pkFieldName - The field names of the PK fields
pkValues - The PK values
Returns:
The new Identity object

buildIdentity

Identity buildIdentity(java.lang.Class realClass,
                       java.lang.String[] pkFieldName,
                       java.lang.Object[] pkValues)
Convenience shortcut method for buildIdentity(java.lang.Class, java.lang.Class, java.lang.String[], java.lang.Object[]).

Parameters:
realClass - The class of the associated object
pkFieldName - The field names of the PK fields
pkValues - The PK values
Returns:
The new Identity object

buildIdentity

Identity buildIdentity(java.lang.Class realClass,
                       java.lang.Object pkValue)
Convenience method for persistent objects with single primary key. NOTE: Do not use for objects with composed PK!

Parameters:
realClass - The class of the associated object
pkValue - The PK value
Returns:
The new Identity object
See Also:
buildIdentity(java.lang.Class, java.lang.String[], java.lang.Object[])

buildIdentity

Identity buildIdentity(java.lang.Class realClass,
                       java.lang.Class topLevelClass,
                       java.lang.Object[] pkValues)
Create a new Identity object based on given arguments - NOTE: There will be no check to resolve the order of the PK values. This method expect the correct order based on the declaration of the FieldDescriptor in the mapping file.

Parameters:
realClass - The class of the associated object
topLevelClass - The top-level class of the associated object
pkValues - The PK values
Returns:
The new Identity object


(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30