On Wed, 10 Nov 2004 21:26:22 +0100, Grzegorz Pypec <[EMAIL PROTECTED]>
wrote:

>Hi,
>
>I have two persistent object in my database: 'film' and 'title'. 
>The object 'film' has reference to object 'title'. (1:1 relation)
>
>When I try delete object 'title' in the following way:
>
><java>
>        (...) 
>       tx.begin();
>       Film film = getFilm();
>       tx.lock(film, Transaction.WRITE);
>      
>        Title title = film.getTitle();        
>        broker.serviceBrokerHelper().unlink(film,"title");
>       //tx.checkpoint();
>        db.deletePersistent(title);
>
>       tx.commit();
>       (...)
></java>
>
>the following error occur:
><error>
>       ERROR: SQLException during the execution of the delete (for a 
>tutor.ojb.odmg.filmoteka.Tytul): 
>       ERROR: update or delete on "title" violates foreign key constraint 
>"film_fk_1" on "film"
></error>
>(First OJB should store the null FK in 'film' then delete object 'title'.)
>
>But when I uncomment  'tx.checkpoint()' everyfing it's OK!!! However in this 
>case all changes in transaction are stored in the database and I can't 
>rollback this changes.
>I guess that OJB can't set correct sequence operations when I commit 
>transaction.
>
>So, my question is: 
>how I can set the correct sequence operations in transaction? 
>Or is there any other method to delete referenced objects?
>
>regards
>
>-- 
>| Grzegorz Pype <gregpyp(at)o2(dot)pl>
>| GG# 3744625
>| 
>| GPG: 21233D71C5C2BD765CF5A69648B26B957FF6CFFE

Instead of tx.checkpoint() you can use ((TransactionExt) tx).flush(),
which flushes all SQL to the DB without commit.

However, normally OJB does a pretty good job in ordering the SQL
correctly. Could it be that you have some cyclic references in your
object model (e.g. A->B and B->A)? 

Gerhard


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to