db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/core PersistenceBrokerImpl.java
Date Thu, 19 Jun 2003 20:05:50 GMT
thma        2003/06/19 13:05:50

  Modified:    src/java/org/apache/ojb/broker/core
                        PersistenceBrokerImpl.java
  Log:
  apply Ollis M:N patch
  
  Revision  Changes    Path
  1.13      +20 -8     db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
  
  Index: PersistenceBrokerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- PersistenceBrokerImpl.java	19 Jun 2003 18:03:51 -0000	1.12
  +++ PersistenceBrokerImpl.java	19 Jun 2003 20:05:49 -0000	1.13
  @@ -759,8 +759,11 @@
               {
                   if (cds.isMtoNRelation() && cds.getCascadeStore())
                   {
  -                    // delete all rows from m:n table belonging to obj
  -                    deleteMtoNImplementor(cds, obj);
  +                    // thma: deleting all entries pointing to obj here is not correct.
  +                    // there could be other m:n entries pointing to obj that were not
  +                    // part of the the now null value collection.
  +                    // they would get deleted too, although nobody asked for it!
  +                    // deleteMtoNImplementor(cds, obj);
                   }
               }
               else
  @@ -772,7 +775,7 @@
                   {
                       continue;
                   }
  -                if (cds.isMtoNRelation() && cds.getCascadeStore())
  +                if (cds.isMtoNRelation())
                   {
                       currentMtoNKeys = getMtoNImplementor(cds, obj);
                       // delete unused m:n implementors
  @@ -801,10 +804,13 @@
                   {
                       Object otherObj = colIterator.next();
                       // for m:n mapped collections store association implementing entries
  -                    if (cds.isMtoNRelation() && cds.getCascadeStore())
  +                    if (cds.isMtoNRelation())
                       {
  -                        // 1. Store depended upon object first to avoid FK violation
  -                        storeCollectionObject(cds, otherObj);
  +                        if (cds.getCascadeStore())
  +                        {
  +                            // 1. Store depended upon object first to avoid FK violation
  +                            storeCollectionObject(cds, otherObj);
  +                        }
                           // 2. Store indirection record
                           storeMtoNImplementor(cds, obj, otherObj, currentMtoNKeys);
                       }
  @@ -1157,7 +1163,7 @@
   	private Query getPKQuery(Identity oid)
   	{
           Object[] values = oid.getPrimaryKeyValues();
  -        ClassDescriptor cld = getClassDescriptor(oid.getObjectsRealClass());
  +        ClassDescriptor cld = getClassDescriptor(oid.getObjectsTopLevelClass());
           FieldDescriptor[] fields = cld.getPkFields();
           Criteria criteria = new Criteria();
   
  @@ -1516,6 +1522,12 @@
       private Object getDBObject(Identity oid) throws ClassNotPersistenceCapableException
       {
           Class c = oid.getObjectsRealClass();
  +
  +        if (c == null)
  +        {
  +            c = oid.getObjectsTopLevelClass();
  +        }
  +
           ClassDescriptor cld = descriptorRepository.getDescriptorFor(c);
           Object newObj = null;
   
  
  
  

Mime
View raw message