db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattba...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/otm/copy ReflectiveObjectCopyStrategy.java
Date Tue, 08 Jul 2003 23:56:30 GMT
mattbaird    2003/07/08 16:56:30

  Modified:    src/test/org/apache/ojb/otm SwizzleTests.java CopyTest.java
               src/java/org/apache/ojb/otm/core BaseConnection.java
               src/java/org/apache/ojb/otm/copy
                        ReflectiveObjectCopyStrategy.java
  Log:
  more changes to support proper swizzling
  
  Revision  Changes    Path
  1.8       +12 -1     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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SwizzleTests.java	8 Jul 2003 23:37:53 -0000	1.7
  +++ SwizzleTests.java	8 Jul 2003 23:56:29 -0000	1.8
  @@ -208,8 +208,19 @@
   		/**
   		 * everything is good, update b
   		 */
  +		_conn.lockForWrite(b1);
   		b1.setValue1("goodbye there");
   		tx.commit();
  +		/**
  +		 * make sure b was updated
  +		 */
  +		tx = _kit.getTransaction(_conn);
  +		tx.begin();
  +		boid = _conn.getIdentity(a.getB());
  +		b1 = (TestClassB) _conn.getObjectByIdentity(boid);
  +		assertTrue(b1 != null);
  +		assertTrue(b1.getValue1().equals("goodbye there"));
  +		tx.commit();
   
   		/**
   		 * now get A again and make sure the related B is updated to reflect
  @@ -222,7 +233,7 @@
   		System.out.println("a2.getB().getValue1()" + a2.getB().getValue1());
   		assertTrue(a2.getB().getValue1().equals("goodbye there"));
   		tx.commit();
  -		clearTestData();		
  +		clearTestData();
   	}
   
   	private void clearTestData() throws LockingException
  
  
  
  1.3       +0 -1      db-ojb/src/test/org/apache/ojb/otm/CopyTest.java
  
  Index: CopyTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/otm/CopyTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CopyTest.java	8 Jul 2003 23:37:53 -0000	1.2
  +++ CopyTest.java	8 Jul 2003 23:56:29 -0000	1.3
  @@ -128,7 +128,6 @@
   		assertTrue(copy.getValue3() == 5);
   		assertTrue(copy.getB() != b);
   		assertTrue(copy.getB().getOid().equals("boid"));
  -		System.out.println("copy.getB().getValue1(): " + copy.getB().getValue1());
   		assertTrue(copy.getB().getValue1().equals("hi there"));
   	}
   
  
  
  
  1.17      +10 -5     db-ojb/src/java/org/apache/ojb/otm/core/BaseConnection.java
  
  Index: BaseConnection.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/core/BaseConnection.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- BaseConnection.java	8 Jul 2003 23:17:44 -0000	1.16
  +++ BaseConnection.java	8 Jul 2003 23:56:30 -0000	1.17
  @@ -183,15 +183,20 @@
           if ((object == null) || !isMaterialized(object))
           {
               object = _pb.getObjectByIdentity(oid);
  -        
  -            if (lock != LockType.WRITE_LOCK)
  +            if (object != null)
               {
  -                copyStrategy = _tx.getKit().getCopyStrategy(oid);
  -                object = copyStrategy.copy(object, _pb);
  +				if (lock != LockType.WRITE_LOCK)
  +				{
  +					copyStrategy = _tx.getKit().getCopyStrategy(oid);
  +					object = copyStrategy.copy(object, _pb);
  +				}
               }
           }
   
  -        _editingContext.insert(oid, object, lock);
  +	    if (object != null)
  +	    {
  +			_editingContext.insert(oid, object, lock);
  +	    }
           return object;
       }
   
  
  
  
  1.4       +13 -1     db-ojb/src/java/org/apache/ojb/otm/copy/ReflectiveObjectCopyStrategy.java
  
  Index: ReflectiveObjectCopyStrategy.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/copy/ReflectiveObjectCopyStrategy.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ReflectiveObjectCopyStrategy.java	8 Jul 2003 23:17:43 -0000	1.3
  +++ ReflectiveObjectCopyStrategy.java	8 Jul 2003 23:56:30 -0000	1.4
  @@ -125,7 +125,19 @@
   			if (broker.getDescriptorRepository().hasDescriptorFor(toCopy.getClass()))
   			{
   				Identity oid = new Identity(toCopy, broker);
  -				toCopy = broker.getObjectByIdentity(oid);
  +				Object temp = broker.serviceObjectCache().lookup(oid);
  +				if (temp == null)
  +				{
  +					temp = broker.getObjectByIdentity(oid);
  +					if (temp != null)
  +					{
  +						toCopy = temp;
  +					}
  +				}
  +				else
  +				{
  +					toCopy = temp;
  +				}
   			}
   		}
   		return internalClone(toCopy, objMap, metadataMap, broker);
  
  
  

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


Mime
View raw message