You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "DiCorpo, Phillip" <ph...@vontu.com> on 2006/01/25 04:43:48 UTC

Removing objects from 1:N relationships in OJB 1.0.4

I'm having a problem removing objects in a 1:N relationship in OJB 1.0.4
using OMDG.  Assume you have an object Role that can have one or more
Permission objects.  If I lock just the Role object for WRITE, remove a
Permission object from this Role, and then commit the transaction I'll
get the following exception:

Caused by: org.apache.ojb.odmg.TransactionAbortedExceptionOJB: Can't
commit objects: Unexpected behaviour, unregistered object to delete:
Permission[1]

In OJB.properties ImplicitLocking=false and Ordering=true.  The
collection descriptor in the Role class descriptor looks something like
the following:

<collection-descriptor name="permissions"
element-class-ref="org.test.Permission" proxy="true"
collection-class="org.apache.ojb.broker.util.collections.RemovalAwareLis
t" auto-delete="object" auto-update="none">

		<inverse-foreignkey field-id-ref="2"/>

</collection-descriptor>

Locking the Permission object before removing it seems to solve the
problem.  Any ideas?  Please let me know if you need any additional
information.  Thanks in advance for the help,

--Phil

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


Re: Removing objects from 1:N relationships in OJB 1.0.4

Posted by Armin Waibel <ar...@apache.org>.
Hi Phil,

DiCorpo, Phillip wrote:
> I'm having a problem removing objects in a 1:N relationship in OJB 1.0.4
> using OMDG.  Assume you have an object Role that can have one or more
> Permission objects.  If I lock just the Role object for WRITE, remove a
> Permission object from this Role, and then commit the transaction I'll
> get the following exception:
> 
> Caused by: org.apache.ojb.odmg.TransactionAbortedExceptionOJB: Can't
> commit objects: Unexpected behaviour, unregistered object to delete:
> Permission[1]
> 
> In OJB.properties ImplicitLocking=false and Ordering=true.  The
> collection descriptor in the Role class descriptor looks something like
> the following:
> 
> <collection-descriptor name="permissions"
> element-class-ref="org.test.Permission" proxy="true"
> collection-class="org.apache.ojb.broker.util.collections.RemovalAwareLis
> t" auto-delete="object" auto-update="none">
> 
> 		<inverse-foreignkey field-id-ref="2"/>
> 
> </collection-descriptor>
> 
> Locking the Permission object before removing it seems to solve the
> problem.  Any ideas?  Please let me know if you need any additional
> information.  Thanks in advance for the help,
> 

You set ImplicitLocking false, in this case the user is responsible to 
lock (register) all objects involved in a tx.
You have two possibilities:
1. Enable ImpliciteLocking at runtime (at begin of your tx) using OJB's 
ODMG extensions
http://db.apache.org/ojb/docu/guides/odmg-guide.html#The+TransactionExt+Interface
2. Lock all involved objects by hand. In your case WRITE lock the 
removed Permission too.

regards,
Armin


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

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