Author: arminw
Date: Sat Mar 4 17:47:40 2006
New Revision: 383267
URL: http://svn.apache.org/viewcvs?rev=383267&view=rev
Log:
check correct store of objects
Modified:
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/CircularTest.java
Modified:
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/CircularTest.java
URL:
http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/CircularTest.java?rev=383267&r1=383266&r2=383267&view=diff
==============================================================================
---
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/CircularTest.java
(original)
+++
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/CircularTest.java
Sat Mar 4 17:47:40 2006
@@ -22,6 +22,7 @@
import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
import org.apache.ojb.broker.metadata.ClassDescriptor;
+import org.apache.ojb.broker.Identity;
import org.apache.ojb.junit.ODMGTestCase;
import org.odmg.OQLQuery;
import org.odmg.Transaction;
@@ -407,6 +408,41 @@
/**
* Handle circuler 1:1 with default methods.
*/
+ public void testBidirectionalWithConstraint() throws Exception
+ {
+ String name = "testBidirectionalWithConstraint_" +
System.currentTimeMillis();
+
+ Shop s1 = new Shop(name + "_1");
+ ShopDetail sd = new ShopDetail(name + "_1");
+
+ TransactionExt tx = (TransactionExt) odmg.newTransaction();
+ tx.begin();
+ database.makePersistent(sd);
+ database.makePersistent(s1);
+ tx.flush();
+ s1.setDetail(sd);
+ sd.setShop(s1);
+ tx.commit();
+
+ tx.begin();
+ tx.getBroker().clearCache();
+ Identity oid = tx.getBroker().serviceIdentity().buildIdentity(s1);
+ Shop newShop = (Shop) tx.getBroker().getObjectByIdentity(oid);
+ tx.commit();
+ assertNotNull(newShop);
+ assertNotNull(newShop.getDetail());
+
+
+ tx.begin();
+ database.deletePersistent(s1);
+ tx.flush();
+ database.deletePersistent(sd);
+ tx.commit();
+ }
+
+ /**
+ * Handle circuler 1:1 with default methods.
+ */
public void testBidirectionalWithConstraint_1a() throws Exception
{
String name = "testBidirectionalWithConstraint_1a_" +
System.currentTimeMillis();
@@ -424,6 +460,14 @@
tx.commit();
tx.begin();
+ tx.getBroker().clearCache();
+ Identity oid = tx.getBroker().serviceIdentity().buildIdentity(s1);
+ Shop newShop = (Shop) tx.getBroker().getObjectByIdentity(oid);
+ tx.commit();
+ assertNotNull(newShop);
+ assertNotNull(newShop.getDetail());
+
+ tx.begin();
database.deletePersistent(s1);
tx.flush();
database.deletePersistent(sd);
@@ -456,6 +500,14 @@
tx.commit();
tx.begin();
+ tx.getBroker().clearCache();
+ Identity oid = tx.getBroker().serviceIdentity().buildIdentity(s1);
+ Shop newShop = (Shop) tx.getBroker().getObjectByIdentity(oid);
+ tx.commit();
+ assertNotNull(newShop);
+ assertNotNull(newShop.getDetail());
+
+ tx.begin();
// madatory to mark object with DB FK constraint first on delete
// (FK from Shop to ShopDetail) then OJB will use this order to
// delete the bidirectional objects
@@ -494,6 +546,14 @@
// this call will now detect the changed FK values of the
bidirectional 1:1 reference
tx.commit();
+ tx.begin();
+ tx.getBroker().clearCache();
+ Identity oid = tx.getBroker().serviceIdentity().buildIdentity(s1);
+ Shop newShop = (Shop) tx.getBroker().getObjectByIdentity(oid);
+ tx.commit();
+ assertNotNull(newShop);
+ assertNotNull(newShop.getDetail());
+
// we using the same tx, thus locking and (ordering) is still disabled
tx.begin();
// madatory to mark object with DB FK constraint first on delete
@@ -529,6 +589,13 @@
tx.getBroker().store(sd);
tx.commit();
+ tx.begin();
+ tx.getBroker().clearCache();
+ Identity oid = tx.getBroker().serviceIdentity().buildIdentity(s1);
+ Shop newShop = (Shop) tx.getBroker().getObjectByIdentity(oid);
+ tx.commit();
+ assertNotNull(newShop);
+ assertNotNull(newShop.getDetail());
tx.begin();
// only for testing, we completely bypass odmg
@@ -571,6 +638,14 @@
// or
// database.makePersistent(s1);
tx.commit();
+
+ tx.begin();
+ tx.getBroker().clearCache();
+ Identity oid = tx.getBroker().serviceIdentity().buildIdentity(s1);
+ Shop newShop = (Shop) tx.getBroker().getObjectByIdentity(oid);
+ tx.commit();
+ assertNotNull(newShop);
+ assertNotNull(newShop.getDetail());
tx.begin();
// with cascading delete and the declared FK constraint OJB
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]