You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2005/12/14 13:19:51 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/broker IdentityFactory.java
arminw 2005/12/14 04:19:51
Modified: src/java/org/apache/ojb/broker/core Tag: OJB_1_0_RELEASE
IdentityFactoryImpl.java
src/java/org/apache/ojb/broker/util/sequence Tag:
OJB_1_0_RELEASE SequenceManagerTransientImpl.java
src/java/org/apache/ojb/broker Tag: OJB_1_0_RELEASE
IdentityFactory.java
Log:
javadoc update
Revision Changes Path
No revision
No revision
1.2.2.4 +12 -10 db-ojb/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
Index: IdentityFactoryImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java,v
retrieving revision 1.2.2.3
retrieving revision 1.2.2.4
diff -u -r1.2.2.3 -r1.2.2.4
--- IdentityFactoryImpl.java 13 Dec 2005 18:21:23 -0000 1.2.2.3
+++ IdentityFactoryImpl.java 14 Dec 2005 12:19:51 -0000 1.2.2.4
@@ -42,7 +42,13 @@
broker.addListener(this, true);
}
- protected Identity createIdentity(ClassDescriptor cld, Object objOrProxy)
+ /**
+ * This methods creates a new transient (if at least one PK field is 'null') or persistent
+ * (if the PK fields are populated) {@link org.apache.ojb.broker.Identity} instance. If the specified object
+ * is transient and former call for the same object returns already a transient Identity, the same transient
+ * Identity object will be returned.
+ */
+ protected Identity createTransientOrRealIdentity(ClassDescriptor cld, Object objOrProxy)
{
if(objOrProxy == null) throw new OJBRuntimeException("Can't create Identity for 'null'-object");
Identity result = null;
@@ -118,13 +124,13 @@
/** @see org.apache.ojb.broker.IdentityFactory#buildIdentity(Object) */
public Identity buildIdentity(Object obj)
{
- return createIdentity(broker.getClassDescriptor(ProxyHelper.getRealClass(obj)), obj);
+ return createTransientOrRealIdentity(broker.getClassDescriptor(ProxyHelper.getRealClass(obj)), obj);
}
/** @see org.apache.ojb.broker.IdentityFactory#buildIdentity(Object) */
public Identity buildIdentity(ClassDescriptor cld, Object obj)
{
- return createIdentity(cld, obj);
+ return createTransientOrRealIdentity(cld, obj);
}
/** @see org.apache.ojb.broker.IdentityFactory#buildIdentity(Class, Class, String[], Object[]) */
@@ -279,24 +285,20 @@
//===================================================================
public void afterBegin(PBStateEvent event)
{
- //activeTx = true;
}
public void afterCommit(PBStateEvent event)
{
- //activeTx = false;
- objectToIdentityMap.clear();
+ if(objectToIdentityMap.size() > 0) objectToIdentityMap.clear();
}
public void afterRollback(PBStateEvent event)
{
- //activeTx = false;
- //objectToIdentityMap.clear();
+ if(objectToIdentityMap.size() > 0) objectToIdentityMap.clear();
}
public void beforeClose(PBStateEvent event)
{
- //activeTx = false;
if(objectToIdentityMap.size() > 0) objectToIdentityMap.clear();
}
No revision
No revision
1.1.2.2 +4 -3 db-ojb/src/java/org/apache/ojb/broker/util/sequence/Attic/SequenceManagerTransientImpl.java
Index: SequenceManagerTransientImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/sequence/Attic/SequenceManagerTransientImpl.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- SequenceManagerTransientImpl.java 13 Dec 2005 20:39:04 -0000 1.1.2.1
+++ SequenceManagerTransientImpl.java 14 Dec 2005 12:19:51 -0000 1.1.2.2
@@ -20,7 +20,8 @@
/**
* For internal use only!
- * This class is used to create identity values for transient objects.
+ * This class is used to create transient primary key values for transient
+ * {@link org.apache.ojb.broker.Identity} objects.
*
* @version $Id$
*/
@@ -42,7 +43,7 @@
/*
arminw:
We need unique 'dummy keys' for new objects before storing.
- Variable 'tempKey' is declared volatile, thus decrement should be atomic
+ Variable 'tempKey' is declared volatile, thus increment should be atomic
*/
return ++tempKey;
}
No revision
No revision
1.2.2.3 +9 -9 db-ojb/src/java/org/apache/ojb/broker/IdentityFactory.java
Index: IdentityFactory.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/IdentityFactory.java,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -r1.2.2.2 -r1.2.2.3
--- IdentityFactory.java 23 Mar 2005 12:39:57 -0000 1.2.2.2
+++ IdentityFactory.java 14 Dec 2005 12:19:51 -0000 1.2.2.3
@@ -14,14 +14,13 @@
* </ul>
* NOTE:
* <br/>
- * It is possible to assign new created objects
- * with a valid UID before they are written to database - more info see {@link org.apache.ojb.broker.Identity}.
- * This should be
- * used with care, because not all {@link org.apache.ojb.broker.util.sequence.SequenceManager}
- * implementations return the "real" UID value before the object was stored (e.g. when database based
- * Identity columns are used, a temporary placeholder is returned).
+ * It is possible to create transient {@link Identity} objects for transient,
+ * "new created" persistence capable objects. But keep in mind that this transient
+ * {@link Identity} object is only valid till the persistence capable object was written
+ * to datastore. After this the {@link Identity} have to be renewed by calling
+ * <code>IdentityFactory.buildIdentity(...)</code> again (then the transient Identity
+ * will be replaced by the persistent Identity).
*
- * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
* @version $Id$
*/
public interface IdentityFactory
@@ -79,7 +78,8 @@
/**
* Create a new {@link 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.
+ * the correct order based on the declaration of the {@link org.apache.ojb.broker.metadata.FieldDescriptor}
+ * in the mapping file.
*
* @param realClass The class of the associated object.
* @param topLevelClass The top-level class of the associated object.
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org