Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 73252 invoked from network); 29 Feb 2004 09:34:55 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 29 Feb 2004 09:34:55 -0000 Received: (qmail 93747 invoked by uid 500); 29 Feb 2004 09:34:30 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 93540 invoked by uid 500); 29 Feb 2004 09:34:29 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 93527 invoked by uid 500); 29 Feb 2004 09:34:29 -0000 Received: (qmail 93522 invoked from network); 29 Feb 2004 09:34:29 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 29 Feb 2004 09:34:29 -0000 Received: (qmail 73239 invoked by uid 1513); 29 Feb 2004 09:34:53 -0000 Date: 29 Feb 2004 09:34:53 -0000 Message-ID: <20040229093453.73238.qmail@minotaur.apache.org> From: brj@apache.org To: db-ojb-cvs@apache.org Subject: cvs commit: db-ojb/src/java/org/apache/ojb/broker/core PersistenceBrokerImpl.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N brj 2004/02/29 01:34:53 Modified: src/java/org/apache/ojb/broker/core PersistenceBrokerImpl.java Log: refactoring of storeCollections Revision Changes Path 1.72 +46 -36 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.71 retrieving revision 1.72 diff -u -r1.71 -r1.72 --- PersistenceBrokerImpl.java 28 Feb 2004 21:42:33 -0000 1.71 +++ PersistenceBrokerImpl.java 29 Feb 2004 09:34:53 -0000 1.72 @@ -901,41 +901,7 @@ Iterator colIterator = getCollectionIterator(cds, col); while (colIterator.hasNext()) { - Object otherObj = colIterator.next(); - - // for m:n mapped collections store association implementing entries - if (cds.isMtoNRelation()) - { - if (cds.getCascadeStore()) - { - // 1. Store depended upon object first to avoid FK violation - store(otherObj); - - // BRJ: store could have inserted MtoNImplementors - // so we need to read them to avoid ref. integrity - // violations - currentMtoNKeys = mtoNBroker.getMtoNImplementor(cds, obj); - } - // 2. Store indirection record - // BRJ: this could cause integrity problems because - // obj may not be stored depending on auto-update - mtoNBroker.storeMtoNImplementor(cds, obj, otherObj, currentMtoNKeys); - } - else - { - // BRJ: do not assign fk if not required - // to avoid materialization of proxy - // olegnitz: but assign if it is not proxy or is materialized - if (cds.getCascadeStore() - || ProxyHelper.isMaterialized(otherObj)) - { - assertFkAssignment(otherObj, obj, cds, insert); - } - if (cds.getCascadeStore()) - { - store(otherObj); - } - } + storeCollectionObject(obj, insert, cds, currentMtoNKeys, colIterator.next()); } // invoke callback on collection @@ -947,6 +913,50 @@ } } + /** + * Store an Object belonging to the collection defined by cds + * @param obj the owner object + * @param insert + * @param cds the collection descriptor + * @param currentMtoNKeys + * @param otherObj the object to be stored + */ + private void storeCollectionObject(Object obj, boolean insert, CollectionDescriptor cds, Collection currentMtoNKeys, Object otherObj) + { + // for m:n mapped collections store association implementing entries + if (cds.isMtoNRelation()) + { + if (cds.getCascadeStore()) + { + // 1. Store depended upon object first to avoid FK violation + store(otherObj); + + // BRJ: store could have inserted MtoNImplementors + // so we need to read them to avoid ref. integrity + // violations + currentMtoNKeys = mtoNBroker.getMtoNImplementor(cds, obj); + } + // 2. Store indirection record + // BRJ: this could cause integrity problems because + // obj may not be stored depending on auto-update + mtoNBroker.storeMtoNImplementor(cds, obj, otherObj, currentMtoNKeys); + } + else + { + // BRJ: do not assign fk if not required + // to avoid materialization of proxy + // olegnitz: but assign if it is not proxy or is materialized + if (cds.getCascadeStore() || ProxyHelper.isMaterialized(otherObj)) + { + assertFkAssignment(otherObj, obj, cds, insert); + } + + if (cds.getCascadeStore()) + { + store(otherObj); + } + } + } /** * Answer the Iterator for Collection or Array --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org