db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Armin Waibel (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (OJB-18) ODMG ordering problem with circular/bidirectional 1:1 references
Date Mon, 12 Dec 2005 12:35:47 GMT
     [ http://issues.apache.org/jira/browse/OJB-18?page=all ]
     
Armin Waibel resolved OJB-18:
-----------------------------

    Fix Version: 1.0.4
     Resolution: Fixed

The user can disable the auto-ordering of persistence capable objects and determine the object
order by hand. 
Additionally a custom attribute 'constraint' was introduced to allow declaration of database
FK constraint within 1:1 reference-descriptor. This allows OJB to incorporate the FK constraint
declaration in the ordering algorithm.

> ODMG ordering problem with circular/bidirectional 1:1 references
> ----------------------------------------------------------------
>
>          Key: OJB-18
>          URL: http://issues.apache.org/jira/browse/OJB-18
>      Project: OJB
>         Type: Bug
>   Components: ODMG-API
>     Versions: 1.0.3
>  Environment: all
>     Reporter: Armin Waibel
>     Assignee: Armin Waibel
>      Fix For: 1.0.4

>
> odmg ordering problem when using circular/bidirectional 1:1 references, in this case
the ordering of objects doesn't change at commit.
> Assume we have A-1:1->AA-1:1->AAA-1:1->A and the user persist the 'A' instance,
then the expected order is
> [AAA, AA, A]
> because start is A (specified by the user) and the last new object of the circuit is
AAA and for 1:1 references OJB first persist the reference. The PB-api show this ordering,
odmg show [A, AA, AAA] in this case.
> The problem is the weight of the vertices in loops or circuits of 1:1 references, because
all vertices have the same weight, so the odering doesn't change.
> *workaround*
> Influence ordering by using TransactionExt.flush or make persist calls in the correct
order for all objects of the circuit
> Example1, loop:
> tx.begin();
> Shop s1 = new Shop(name + "_1");
> // when using flush() we can use the "natural" order
> // without getting DB constraint violence.
> database.makePersistent(s1);
> // write to DB object without references
> tx.flush();
> ShopDetail sd = new ShopDetail(name + "_1");
> // now set references
> s1.setDetail(sd);
> sd.setShop(s1);
> // no need to persist the ShopDetail object
> // (will be detected by OJB)
> // but it doesn't matter if you do
> // database.makePersistent(sd);
> tx.commit();
> Example2, loop:
> tx.begin();
> Shop s1 = new Shop(name + "_1");
> ShopDetail sd = new ShopDetail(name + "_1");
> s1.setDetail(sd);
> sd.setShop(s1);
> // madatory to persist referenced ShopDetail first, the Shop
> // object will be detected automatic. In this case first the ShopDetail
> // will be created and then the Shop
> database.makePersistent(sd);
> database.makePersistent(s1);
> tx.commit();

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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