db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/odmg PersonWithArrayTest.java
Date Thu, 24 Feb 2005 17:12:19 GMT
arminw      2005/02/24 09:12:19

  Modified:    src/java/org/apache/ojb/odmg Tag: OJB_1_0_RELEASE
                        ObjectEnvelope.java
               src/test/org/apache/ojb/odmg Tag: OJB_1_0_RELEASE
                        PersonWithArrayTest.java
  Log:
  fix problem with proxy objects
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.32.2.6  +25 -1     db-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelope.java
  
  Index: ObjectEnvelope.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelope.java,v
  retrieving revision 1.32.2.5
  retrieving revision 1.32.2.6
  diff -u -r1.32.2.5 -r1.32.2.6
  --- ObjectEnvelope.java	7 Feb 2005 20:42:42 -0000	1.32.2.5
  +++ ObjectEnvelope.java	24 Feb 2005 17:12:18 -0000	1.32.2.6
  @@ -519,7 +519,31 @@
           while (newIter.hasNext())
           {
               Object newObj = newIter.next();
  -            if ((oldCol == null) || (!oldCol.contains(newObj)))
  +            /*
  +            arminw:
  +            workaround, if the new object is an proxy object we have to
  +            compare the Identity objects
  +            */
  +            if(oldCol != null && ProxyHelper.isProxy(newObj))
  +            {
  +                Identity oidNew = ProxyHelper.getIndirectionHandler(newObj).getIdentity();
  +                boolean isNew = true;
  +                for(Iterator iterator = oldCol.iterator(); iterator.hasNext();)
  +                {
  +                    Identity oidOld =  getBroker().serviceIdentity().buildIdentity(iterator.next());
  +                    if(oidNew.equals(oidOld))
  +                    {
  +                        isNew = false;
  +                        break;
  +                    }
  +                }
  +                if(isNew)
  +                {
  +                    ObjectEnvelope mod = buffer.get(newObj, true);
  +                    mod.setModificationState(mod.getModificationState().markNew());
  +                }
  +            }
  +            else if ((oldCol == null) || (!oldCol.contains(newObj)))
               {
                   ObjectEnvelope mod = buffer.get(newObj, true);
                   mod.setModificationState(mod.getModificationState().markNew());
  
  
  
  No                   revision
  No                   revision
  1.6.2.4   +2 -2      db-ojb/src/test/org/apache/ojb/odmg/PersonWithArrayTest.java
  
  Index: PersonWithArrayTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/PersonWithArrayTest.java,v
  retrieving revision 1.6.2.3
  retrieving revision 1.6.2.4
  diff -u -r1.6.2.3 -r1.6.2.4
  --- PersonWithArrayTest.java	7 Feb 2005 17:38:22 -0000	1.6.2.3
  +++ PersonWithArrayTest.java	24 Feb 2005 17:12:19 -0000	1.6.2.4
  @@ -242,12 +242,12 @@
           qry.bind(firstnameFather);
           result = (Collection) qry.execute();
           tx.commit();
  +        assertEquals("Exactly one element in result set", 1, result.size());
   
           tx.begin();
  -        assertEquals("Exactly one element in result set", 1, result.size());
           Person returnedFather = (Person) result.iterator().next();
           // should retrieve new instance, cause we clear the cache
  -        assertTrue("not same", returnedFather != father);
  +        assertTrue("not same instance expected", returnedFather != father);
           Person[] returnedChildren = returnedFather.getChildren();
           assertNotNull(returnedChildren);
           assertEquals(2, returnedChildren.length);
  
  
  

---------------------------------------------------------------------
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