Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 12352 invoked from network); 28 Mar 2004 11:05:20 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 28 Mar 2004 11:05:20 -0000 Received: (qmail 81706 invoked by uid 500); 28 Mar 2004 11:04:52 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 81673 invoked by uid 500); 28 Mar 2004 11:04:52 -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 81660 invoked by uid 500); 28 Mar 2004 11:04:52 -0000 Received: (qmail 81653 invoked from network); 28 Mar 2004 11:04:52 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 28 Mar 2004 11:04:52 -0000 Received: (qmail 12329 invoked by uid 1513); 28 Mar 2004 11:05:18 -0000 Date: 28 Mar 2004 11:05:18 -0000 Message-ID: <20040328110518.12328.qmail@minotaur.apache.org> From: brj@apache.org To: db-ojb-cvs@apache.org Subject: cvs commit: db-ojb/xdocs tutorial3.xml 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/03/28 03:05:18 Modified: xdocs tutorial3.xml Log: added some warnings about referential integrity Revision Changes Path 1.33 +41 -32 db-ojb/xdocs/tutorial3.xml Index: tutorial3.xml =================================================================== RCS file: /home/cvs/db-ojb/xdocs/tutorial3.xml,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- tutorial3.xml 28 Mar 2004 02:31:56 -0000 1.32 +++ tutorial3.xml 28 Mar 2004 11:05:16 -0000 1.33 @@ -293,20 +293,20 @@
  • none On updating or inserting of the main object with PersistenceBroker.store(...), - the referenced object was NOT updated by default.The reference will be not inserted or + the referenced object will NOT be updated by default.The reference will not be inserted or updated, the link to the reference (foreign key value to the reference) on the main object - will be not assigned automatic. The user has to link the main object and to store the reference before - the main object. + will not be assigned automatically. The user has to link the main object and to store the reference before + the main object to avoid violation of referential integrity.
  • link On updating or inserting of the main object with PersistenceBroker.store(...), - the FK assignment on the main object was done automatic. OJB read the PK from the reference object and set these - values as FK in main object. But the referenced object was not touched. If no reference object was found, the FK - will be nullified. (On insert it is allowed to set the FK without populate the referenced object) + the FK assignment on the main object was done automatic. OJB reads the PK from the referenced object and sets these + values as FK in main object. But the referenced object remains untouched. If no referenced object is found, the FK + will be nullified. (On insert it is allowed to set the FK without populating the referenced object)
  • object On updating or inserting of the main object with PersistenceBroker.store(...), - the reference object was stored first, then OJB does the same as in link. + the referenced object will be stored first, then OJB does the same as in link.
  • false @@ -324,8 +324,8 @@
    • none - On deleting an object with PersistenceBroker.delete(...) the referenced object was - NOT touched. + On deleting an object with PersistenceBroker.delete(...) the referenced object will + NOT be touched.
    • link @@ -333,7 +333,7 @@
    • object - On deleting an object with PersistenceBroker.delete(...) the referenced object was + On deleting an object with PersistenceBroker.delete(...) the referenced object will be deleted too.
    • @@ -580,18 +580,20 @@
      • none On updating or inserting of the main object with PersistenceBroker.store(...), - the referenced objects are NOT updated by default. The referenced objects will be not inserted or + the referenced objects are NOT updated by default. The referenced objects will not be inserted or updated, the referenced objects will not be linked (foreign key assignment on referenced objects) - automatic. The user has to link and to store the referenced objects after storing the main object. + to the main object automatically. + The user has to link and to store the referenced objects after storing the main object + to avoid violation of referential integrity.
      • link On updating or inserting of the main object with PersistenceBroker.store(...), - the referenced objects are NOT updated by default. The referenced objects will be not inserted or - updated, but the referenced objects will be linked automatic (FK assignment). + the referenced objects are NOT updated by default. The referenced objects will not be inserted or + updated, but the referenced objects will be linked automatically (FK assignment) the main object.
      • object On updating or inserting of the main object with PersistenceBroker.store(...), - the referenced objects will be linked and stored automatic. + the referenced objects will be linked and stored automatically.
      • false @@ -609,7 +611,8 @@
      • none On deleting an object with PersistenceBroker.delete(...) the referenced objects are - NOT touched. + NOT touched. This may lead to violation of referential integrity if the referenced objects + are childs of the main object. In this case the referenced objects have to be deleted manually first.
      • link @@ -940,20 +943,23 @@
        • none On updating or inserting of the main object with PersistenceBroker.store(...), - the referenced objects are NOT updated by default. The referenced objects will be not inserted or + the referenced objects are NOT updated by default. The referenced objects will not be inserted or updated, the referenced objects will not be linked (creation of FK entries in the indirection table) - automatic. The user has to store the main object, the referenced objects and to link the - m:n relation after storing of all objects. + automatically. The user has to store the main object, the referenced objects and to link the + m:n relation after storing of all objects. establishing the m:n relationship before + storing main and referenced objects may violate referential integrity.
        • link On updating or inserting of the main object with PersistenceBroker.store(...), - the referenced objects are NOT updated by default. The referenced objects will be not inserted or - updated, but the m:n relation was linked automatic (creation of FK entries in the indirection table). -
          NOTE: Make sure that the referenced objects exist in database before store main object. + the referenced objects are NOT updated by default. The referenced objects will not be inserted or + updated, but the m:n relation will be linked automatically (creation of FK entries in the indirection table). +
          + NOTE: Make sure that the referenced objects exist in database before storing the main object + to avoid violation of referential integrity.
        • object On updating or inserting of the main object with PersistenceBroker.store(...), - the referenced objects will be linked and stored automatic. + the referenced objects will be linked and stored automatically.
        • false @@ -971,7 +977,8 @@
        • none On deleting an object with PersistenceBroker.delete(...) the referenced objects are - NOT touched. + NOT touched. The corresponding entries of the main object in the indirection table will not be removed. + This may lead to violation of referential integrity depending on the definition of the indirection table.
        • link @@ -1099,18 +1106,20 @@

          If in reference-descriptor or collection-descriptor the auto-update or - auto-delete attributes are set to none, OJB do not touch the referenced objects on insert, - update or delete operations of the main object. The user has to take care of correct handling of - referenced objects. + auto-delete attributes are set to none, OJB does not touch the referenced objects on insert, + update or delete operations of the main object. The user has to take care of the correct handling of + referenced objects. + When using referential integrity (who does not ?) it's essential that insert and delete operations are done + in the correct sequence.

          One important thing is assignment of the FK values. The assign of the FK values is transcribed with link references in OJB. In 1:1 references the main object has a FK to the referenced object, in 1:n - references the referenced objects has a FK to the main object and in non-decomposed m:n relations - a indirection table with FK values from both sides was used. + references the referenced objects have FK pointing to the main object and in non-decomposed m:n relations + a indirection table containing FK values from both sides of the relationship is used.

          - OJB provide some helper methods for manual reference linking (assignment of the FK) in + OJB provides some helper methods for linking references manually (assignment of the FK) in org.apache.ojb.broker.util.BrokerHelper class. public void link(Object obj, boolean insert) @@ -1124,7 +1133,7 @@

          NOTE: The link/unlink methods are only useful if you set auto-update/-delete to none. In - all other cases OJB handle the link/unlink of references internally. It is also possible to set all FK values by + all other cases OJB handles the link/unlink of references internally. It is also possible to set all FK values by hand without using the link/unlink service methods.

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