You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by we...@apache.org on 2003/10/17 02:52:09 UTC
cvs commit: jakarta-jetspeed-2/plugin/src/java/org/apache/jetspeed/persistence/impl OJBODMGPersistencePlugin.java
weaver 2003/10/16 17:52:09
Modified: plugin/src/java/org/apache/jetspeed/persistence/impl
OJBODMGPersistencePlugin.java
Log:
had to make delete() method use the PB direct as ODMG calls were ignoring the auto-delete
cascading properties in the repository
Revision Changes Path
1.3 +35 -28 jakarta-jetspeed-2/plugin/src/java/org/apache/jetspeed/persistence/impl/OJBODMGPersistencePlugin.java
Index: OJBODMGPersistencePlugin.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/plugin/src/java/org/apache/jetspeed/persistence/impl/OJBODMGPersistencePlugin.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- OJBODMGPersistencePlugin.java 15 Aug 2003 18:37:14 -0000 1.2
+++ OJBODMGPersistencePlugin.java 17 Oct 2003 00:52:09 -0000 1.3
@@ -53,7 +53,6 @@
*/
package org.apache.jetspeed.persistence.impl;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.fulcrum.InitializationException;
@@ -210,7 +209,7 @@
// 1. Start the transaction
TransactionImpl tx = (TransactionImpl) odmg.newTransaction();
tx.begin();
-
+
// 2. remove object from the OJB cache
PersistenceBroker pb = tx.getBroker();
//pb.removeFromCache(object);
@@ -227,7 +226,7 @@
//BeanUtils.copyProperties(object, object);
// 5. Commit the transaction
- tx.commit();
+ tx.commit();
}
catch (Throwable e)
@@ -242,31 +241,40 @@
*/
public void delete(Object object)
{
- // PersistenceBroker pb1 = getBroker();
+ // // PersistenceBroker pb1 = getBroker();
+ // try
+ // {
+ // // 1. Start the transaction
+ // TransactionImpl tx = (TransactionImpl) odmg.newTransaction();
+ //
+ // // 2. remove object from the OJB cache
+ //
+ // tx.begin();
+ // PersistenceBroker pb = tx.getBroker();
+ // pb.removeFromCache(object);
+ // Identity id = new Identity(object, pb);
+ // // 3. retreive a "stale" version of this object from the db
+ //
+ // Object staleObject = pb.getObjectByIdentity(id);
+ // tx.lock(staleObject, Transaction.WRITE);
+ // db.deletePersistent(staleObject);
+ // pb.removeFromCache(staleObject);
+ //
+ // // 5. Commit the transaction
+ // tx.commit();
+ // }
+ // finally
+ // {
+ // // releaseBroker(pb1);
+ // }
+ PersistenceBroker pb = getBroker();
try
{
- // 1. Start the transaction
- TransactionImpl tx = (TransactionImpl) odmg.newTransaction();
-
- // 2. remove object from the OJB cache
-
- tx.begin();
- PersistenceBroker pb = tx.getBroker();
- pb.removeFromCache(object);
- Identity id = new Identity(object, pb);
- // 3. retreive a "stale" version of this object from the db
-
- Object staleObject = pb.getObjectByIdentity(id);
- tx.lock(staleObject, Transaction.WRITE);
- db.deletePersistent(staleObject);
- pb.removeFromCache(staleObject);
-
- // 5. Commit the transaction
- tx.commit();
+ pb.delete(object);
}
finally
{
- // releaseBroker(pb1);
+ releaseBroker(pb);
}
}
@@ -275,7 +283,7 @@
* @see org.apache.jetspeed.services.persistence.ODMGPersistencePlugin#newODMGTransaction()
*/
public Transaction newODMGTransaction()
- {
+ {
return odmg.newTransaction();
}
@@ -283,7 +291,7 @@
* @see org.apache.jetspeed.services.persistence.ODMGPersistencePlugin#newOQLQuery()
*/
public OQLQuery newOQLQuery()
- {
+ {
return odmg.newOQLQuery();
}
@@ -294,10 +302,9 @@
{
Transaction tx = odmg.newTransaction();
tx.begin();
- tx.lock(object, Transaction.WRITE);
+ tx.lock(object, Transaction.WRITE);
tx.commit();
-
-
+
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org