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 ol...@apache.org on 2003/09/09 21:35:12 UTC

cvs commit: db-ojb/src/test/org/apache/ojb/otm SwizzleTests.java

olegnitz    2003/09/09 12:35:12

  Modified:    src/java/org/apache/ojb/otm/core ConcreteEditingContext.java
               src/test/org/apache/ojb/otm SwizzleTests.java
  Log:
  Fixed a bug in creation of objects with non-dependent relationships
  
  Revision  Changes    Path
  1.29      +6 -3      db-ojb/src/java/org/apache/ojb/otm/core/ConcreteEditingContext.java
  
  Index: ConcreteEditingContext.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/core/ConcreteEditingContext.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- ConcreteEditingContext.java	25 Aug 2003 19:26:07 -0000	1.28
  +++ ConcreteEditingContext.java	9 Sep 2003 19:35:12 -0000	1.29
  @@ -237,8 +237,8 @@
                       else
                       {
                           // don't create the object by reachability
  -                        // just invalidate it
  -                        entry.object = null;
  +                        // just do nothing
  +                        return null;
                       }
                   }
   
  @@ -313,7 +313,10 @@
           ContextEntry entry;
   
           entry = insertInternal(oid, object, LockType.WRITE_LOCK, true, false);
  -        entry.state = entry.state.deletePersistent();
  +        if (entry != null)
  +        {
  +            entry.state = entry.state.deletePersistent();
  +        }
           _order.remove(oid);
           _order.add(oid);
       }
  
  
  
  1.12      +49 -0     db-ojb/src/test/org/apache/ojb/otm/SwizzleTests.java
  
  Index: SwizzleTests.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/otm/SwizzleTests.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SwizzleTests.java	20 Aug 2003 20:52:02 -0000	1.11
  +++ SwizzleTests.java	9 Sep 2003 19:35:12 -0000	1.12
  @@ -353,6 +353,55 @@
           clearTestData();
       }
   
  +	 public void testSwizzle4() throws TransactionException, LockingException, PBFactoryException, PersistenceBrokerException
  +    {
  +        clearTestData();
  +        TestClassA a = generateTestData();
  +		TestClassB b = a.getB();
  +        Transaction tx = _kit.getTransaction(_conn);
  +        b.setA(a);
  +
  +        tx.begin();
  +        _conn.makePersistent(a.getB());
  +        _conn.makePersistent(a);
  +        tx.commit();
  +        /**
  +        * clear to start test
  +        */
  +        _conn.invalidateAll();
  +        tx = _kit.getTransaction(_conn);
  +        tx.begin();
  +        /**
  +		 * load B
  +		 */
  +		Identity oidb = _conn.getIdentity(b);
  +        TestClassB b1 = (TestClassB) _conn.getObjectByIdentity(oidb);
  +		/**
  +		 * load A
  + 		 */
  +		Identity oida = _conn.getIdentity(a);
  +		TestClassA a1 = (TestClassA) _conn.getObjectByIdentity(oida);
  +		assertTrue(a1 != null);
  +		assertTrue(a1.getB().equals(b1));
  +		assertTrue(b1.getA().equals(a1));
  +        /**
  +		 * update B
  +		 */
  +        a.setValue1("a");
  +        _conn.makePersistent(a);
  +
  +		/**
  +		 * B, as navigated from A, should be the same as B gotten directly.
  +		 */
  +		assertTrue(a1.getValue1().equals(a.getValue1()));
  +        tx.commit();
  +
  +		/**
  +		 * clear
  +		 */
  +        clearTestData();
  +    }
  +
       private void clearTestData() throws LockingException
       {
           TestClassA a = generateTestData();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org