Hi,

mananthakris wrote:
This is the pseudo code

Question - base class MultipleChoice question - Subclass of question
AssessmentGroup - 1: n with Question
(MultipleChoice  and other sub classes of Question are in the same table
identified by objconcreteclass)


code
Transaction tx - odmg.currentTransaction();
tx.lock (mutliplechoiceobj)
db.deletePersistent(multiplechoiceobj)

Detailed log shows that MutipleChoice is registered and locked, but the
exception says


This is a strange exception. I didn't find a bug in the source code. OJB compares the Identity images of the referenced objects (1:n Question): If in the new image an Identity from the old image is not contained, the object was deleted during tx. In this case OJB try to mark the object for deletion.

> tx.lock (mutliplechoiceobj)

Is "mutliplechoiceobj" a instance of AssessmentGroup? Is implicit locking enabled? If not OJB will lock/register "mutliplechoiceobj" without the referenced objects.


Unexpected behaviour, unregistered object to delete:
com.tk20.bo.evaluationinstrument.Question{100007f15c458c10ff4485144-7d2d},
main object is
com.tk20.bo.template.AssessmentGroup{100007f15c458c10ff4485144-7d2f},
envelope object is
[EMAIL PROTECTED],ModificationState=org.apache.ojb.odmg.states.StateOldDelete]


Why does it try to see whether the base class is registered or not? Should
it not identify the exact subclass it is


OJB logs only the Identity and Identity.toString only print the top-level class + PK's (will improve Identity.toString method for OJB 1.0.5 to avoid confusion).


I modified the repository_user.xml for mappings for AssessmentGroup
<collection-descriptor
        name="questionsInternal"
collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList"
        element-class-ref="com.tk20.bo.evaluationinstrument.Question"
        auto-retrieve="true"
        auto-update="object"
        auto-delete="object">
       <inverse-foreignkey field-ref="assessmentGroupPk"/>
     </collection-descriptor>

Mappings for MutlipleChoice and Question  as
 <reference-descriptor
        name="assessmentGroup"
        class-ref="com.tk20.bo.template.AssessmentGroup"
        auto-retrieve="true"
        auto-update="none"
        auto-delete="object">
       <foreignkey field-ref="assessmentGroupPk"/>
     </reference-descriptor>

Which version of OJB do you use? It's not allowed to set attribute "auto-update" different from "none", else you could get unexpected behavior.
http://db.apache.org/ojb/docu/guides/odmg-guide.html#Specific+Metadata+Settings

regards,
Armin










arminw wrote:
Hi,

mananthakris wrote:
I checked that our repository_user file does not contain auto_XXX for an
reference-desc and collection-desc, are these mandatory and could be
cause
of problems?

It seems that OJB can't find the Question object in intern object registry using it's Identity. OJB detect that the object no longer exists in the 1:n reference and try to remove the Question object.

To enable cascading delete it's mandatory to set auto-delete="object".
http://db.apache.org/ojb/docu/guides/odmg-guide.html#Specific+Metadata+Settings

Could you please post the used source or pseudo code?

regards,
Armin

mananthakris wrote:
Hi,
We are using same table for different subclasses using a varchar column
and define  ojbConcreteClass  to find the actual class.

When we try to delete a object in a relationship , i see an error
"unregistered object for delete:" . I saw a previous forum question,
suggestion for the error and implemented writing locks for all objects
in
transaction, but we still have the error.

In our case we have an object AssessmentGroup and an object Question in
1:n relationship ( Question has different types of questions /subclasses
in a same table differentiated with classidentity column of the table).

This error occurs when we delete a MultipleChoice sublclass of Question
and remove its relationship with AssessmentGroup.

Detailed logs shows we are locking
AssessmentGroup,MultipleChoice(subclass) before delete,
but the exception shows even when we are writing
db.deletePersistent(multiplechoiceobj) , it is trying to delete base
class
internally. Do you think this is expected behaviour? Are we supposed to
lock base class inspite of knowing which exact class we are deleting?

The exception is

org.apache.ojb.odmg.Image$ImageException: Unexpected behaviour,
unregistered object to delete:
com.tk20.bo.evaluationinstrument.Question{100007f1388e5e10fe3fa0849-7ff1},
main object is
com.tk20.bo.template.AssessmentGroup{100007f1388e5e10fe3fa0849-7ff3},
envelope object is
[EMAIL PROTECTED],ModificationState=org.apache.ojb.odmg.states.StateOldClean]


We are using obj 1.0.4 odmg api with mysql db.Attached is the
repository_user.xml
http://www.nabble.com/file/5190/repository_user.xml repository_user.xml
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





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

Reply via email to