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 2007/08/02 17:31:36 UTC
svn commit: r562137 -
/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
Author: arminw
Date: Thu Aug 2 08:31:35 2007
New Revision: 562137
URL: http://svn.apache.org/viewvc?view=rev&rev=562137
Log:
rename of non public methods, minor enhancements
Modified:
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java?view=diff&rev=562137&r1=562136&r2=562137
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java Thu Aug 2 08:31:35 2007
@@ -84,6 +84,7 @@
import org.apache.ojb.broker.util.ClassHelper;
import org.apache.ojb.broker.util.IdentityHashSet;
import org.apache.ojb.broker.util.ObjectModification;
+import org.apache.ojb.broker.util.IdentityArrayList;
import org.apache.ojb.broker.util.configuration.Configuration;
import org.apache.ojb.broker.util.configuration.ConfigurationException;
import org.apache.ojb.broker.util.logging.Logger;
@@ -165,7 +166,7 @@
with user implemented equals/hashCode methods of persistence capable objects
(e.g. objects are equals but PK fields not)
*/
- private Collection nowStoring = new IdentityHashSet();
+ private Collection nowStoring = new IdentityArrayList();
/**
* Lists for object registration during delete operations.
@@ -174,13 +175,13 @@
*/
/*
arminw: list was cleared before delete method end. Internal we only
- call doDelete(...) method. Same procedure as 'nowStoring'
+ call internalDelete(...) method. Same procedure as 'nowStoring'
we use an object identity based List to compare objects to prevent problems
with user implemented equals/hashCode methods of persistence capable objects
(e.g. objects are equals but PK fields not)
*/
- private Collection markedForDelete = new IdentityHashSet();
+ private Collection nowDeleting = new IdentityArrayList();
/**
* Used for performance optimization of method
@@ -609,11 +610,11 @@
{
ClassDescriptor cld = getClassDescriptor(getProxyFactory().getRealClass(obj));
Identity oid = serviceIdentity().buildIdentity(cld, obj);
- doDelete(obj, oid, cld, ignoreReferences);
+ internalDelete(obj, oid, cld, ignoreReferences);
}
finally
{
- markedForDelete.clear();
+ nowDeleting.clear();
}
}
@@ -628,11 +629,11 @@
doTxCheck();
try
{
- doDelete(obj, oid, cld, ignoreReferences);
+ internalDelete(obj, oid, cld, ignoreReferences);
}
finally
{
- markedForDelete.clear();
+ nowDeleting.clear();
}
}
@@ -646,9 +647,9 @@
/**
* do delete given object. Should be used by all intern classes to delete
- * objects.
+ * objects of an object graph.
*/
- private void doDelete(Object obj, Identity oid, ClassDescriptor cld, boolean ignoreReferences)
+ private void internalDelete(Object obj, Identity oid, ClassDescriptor cld, boolean ignoreReferences)
throws PersistenceBrokerException
{
// replace specified object with the real one
@@ -663,7 +664,7 @@
use object identity based list, because using objects we get a
better performance. I can't find side-effects in doing so.
*/
- if (markedForDelete.contains(obj))
+ if (nowDeleting.contains(obj))
{
return;
}
@@ -682,7 +683,7 @@
* MBAIRD
* 2. register object in markedForDelete map.
*/
- markedForDelete.add(obj);
+ nowDeleting.add(obj);
// Invoke events on PersistenceBrokerAware instances and listeners
BEFORE_DELETE_EVENT.setTarget(obj);
@@ -868,7 +869,7 @@
}
else
{
- doDelete(referencedObject, null, null, ignoreReferences);
+ internalDelete(referencedObject, null, null, ignoreReferences);
}
}
}
@@ -913,7 +914,7 @@
Iterator colIterator = BrokerHelper.getCollectionIterator(col);
while (colIterator.hasNext())
{
- doDelete(colIterator.next(), null, null, false);
+ internalDelete(colIterator.next(), null, null, false);
}
}
}
@@ -925,7 +926,7 @@
* Store only transient/new objects, if the object is persistent (is already
* stored) it's skipped - no update will be performed.
*/
- public void storeOnlyNew(Object obj) throws PersistenceBrokerException
+ void storeOnlyNew(Object obj) throws PersistenceBrokerException
{
Class clazz = getProxyFactory().getRealClass(obj);
ClassDescriptor cld = getClassDescriptor(clazz);
@@ -1092,20 +1093,29 @@
return;
}
Iterator i = listRds.iterator();
+ ObjectReferenceDescriptor superReference = null;
while (i.hasNext())
{
ObjectReferenceDescriptor rds = (ObjectReferenceDescriptor) i.next();
/*
arminw: the super-references (used for table per subclass inheritance) must
be performed in any case. The "normal" 1:1 references can be ignored when
- flag "ignoreReferences" is set
+ flag "ignoreReferences" is set.
+ But in any case the super-reference have to be performed as last!
*/
- if((!ignoreReferences && !rds.isCascadingStoreNone())
- || rds.isSuperReferenceDescriptor())
+ if(rds.isSuperReferenceDescriptor())
+ {
+ superReference = rds;
+ }
+ else if((!ignoreReferences && !rds.isCascadingStoreNone()))
{
storeAndLinkOneToOne(false, obj, cld, rds, insert);
}
}
+ if(superReference != null)
+ {
+ storeAndLinkOneToOne(false, obj, cld, superReference, insert);
+ }
}
/**
@@ -1151,7 +1161,7 @@
// get all members of obj that are collections and store all their elements
Collection listCods = cld.getCollectionDescriptors();
// return if nothing to do
- if (listCods.size() == 0)
+ if (listCods.isEmpty())
{
return;
}
@@ -1267,8 +1277,8 @@
- on insert we link and insert the referenced objects, because the proxy
collection maybe "inherited" from the object before the PK was replaced
*/
- if(insert || !(referencedObjects instanceof CollectionProxyDefaultImpl
- && !((CollectionProxyDefaultImpl) referencedObjects).isLoaded()))
+ if(insert || !(referencedObjects instanceof CollectionProxy
+ && !((CollectionProxy) referencedObjects).isLoaded()))
{
Iterator it = BrokerHelper.getCollectionIterator(referencedObjects);
Object refObj;
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org