I've spent all day looking at it. Doesn't seem to be anything wrong. Have
built a fairly extensive JUnit test which seems to confirm my earlier
results.

I also have a problem with child dependent objects ( 1 to many ) not
obtaining a reference back to the parent object, and therefore not being
loaded into the parents collection.

Tests work until I turn caching off, or I do a query of the database once
castor has restarted (hence clearing the cache, suprise suprise).

I'm using UUID key generation. I've come across some similiar problems in a
post back about a week ago tittled
"[castor-dev] Reference to an object not persisted".   They were using JBoss
and claimed the problem didn't used to exist. Maybe a bug has crept into the
code.

Both these problems seem to relate to key generation. The child objects are
created (when dependent, not when many-to-many) but the relationships
aren't.

>From my limited conceptual understanding of castor, it seems to me the
parent objects are created first, then the children along with their ids.
Instead children identifiers should be allocated first, then the parents
created, then the children.

I've changed things in my mapping file to turn caches on/off, lazy on/off,
required on/off but nothing seems to work. I can't use MAX key-gen as I use
strings, not Integers.

You make any head or tail of this? If there is anything unclear I can make
up some examples of what happens and all.

( on an aside:  why can't Castor use a mapping table for one to many
relationships? That way child classes won't need a reference back to the
parent. I would imagine they could be loaded in much the same way as a
many-to-many, except instead of returning a collection, a single object is
returned. )

Thanks,
Bert.

----- Original Message -----
From: "Thomas Yip" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, January 20, 2002 10:39 AM
Subject: Re: [castor-dev] New child objects in m:n relation not created in
Persistent storage when creating new parent


>
> First, m:n relationship can't be dependent. But, I
> assume you've already tried non dependent first.
>
> I don't aware any bug causing your problem.
> The test case for m:n relationship is working.
>
> Please take a close look into the test to see if
> there is something you missed.
>
>
>
> Thomas
>
>
> -----Original Message-----
> >From: Bert van Brakel [mailto:[EMAIL PROTECTED]]
> >Sent: Saturday, January 19, 2002 4:03 AM
> >To: [EMAIL PROTECTED]
> >Subject: Re: [castor-dev] New child objects in m:n relation not created
in
> Persistent storage when creating new parent
> >
> >Sorry, I've tried that but it doesn't work.
> >
> >If the permission  id is null castor throws an error, if I set the
> >id to a empty string it creates the child objects with correct
> >generated ids, but there is only one relation in the
> >role_permission_map table (correct role id, empty string permission id).
> >
> >If I set the permission ids (unique)  before adding them to the role,
> >the role_permission_map contains two relations between the role
> >and the permissions using the correct role id, and the original
> >permission ids (the ones I set). But the permissions table contains
> >the permissions with autogenerated ids (different from the ones i
> >had given the permissions).
> >
> >So, in the end I still have to create the permissions using db.create(
> permission ).
> >
> >Bert.
> >----- Original Message -----
> >From: Thomas Yip <mailto:[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> >Sent: Friday, January 18, 2002 8:52 AM
> >Subject: Re: [castor-dev] New child objects in m:n relation not created
in
> Persistent storage when creating new parent
> >
> >
> >Have you try to setAutoStore( true )?
> >It will create reachable independent object automatically.
> >Remember to call it before you start the transaction
> >
> >
> >Thomas
> >
> >
> >-----Original Message-----
> >>From: Bert van Brakel [mailto:[EMAIL PROTECTED]]
> >>Sent: Thursday, January 17, 2002 2:11 AM
> >>To: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> >>Subject: Re: [castor-dev] New child objects in m:n relation not created
in
> Persistent storage when creating new parent
> >>
> >>Unfortunately I think so too. Permissions are seperate entities in
> storage. I want them created automatically, but not deleted. I can't make
> permissions dependent for that reason.
> >>
> >>Oh well, I'll have to live with it then, unless anyone else has any
bright
> ideas.
> >>
> >>Bert
> >>----- Original Message -----
> >>>From: Christopher Sturm <mailto:[EMAIL PROTECTED]>
> >>>To: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> >>>Sent: Thursday, January 17, 2002 2:16 PM
> >>>Subject: Re: [castor-dev] New child objects in m:n relation not created
> in Persistent storage when creating new parent
> >>>
> >>>I think your Permission class should depend on your Role class in the
> mapping.
> >>>
> >>><class name="Permission " identity="id">
> >>>    <field name="role" type="Role">
> >>>   </field>
> >>>  </class>
> >>>
> >>>  <class name="Role" identity="id" depends="Permission">
> >>>      <field name="permission" type="Permission">
> >>>      </field>
> >>>  </class>
> >>>
> >>>Otherwise you need to create the Permission objects first and then
create
> your Role.
> >>>-----Original Message-----
> >>>From: Bert van Brakel [mailto:[EMAIL PROTECTED]]
> >>>Sent: Wednesday, January 16, 2002 5:01 PM
> >>>To: [EMAIL PROTECTED]
> >>>Subject: [castor-dev] New child objects in m:n relation not created in
> Persistent storage when creating new parent
> >>>Why does castor not create new child objects in persistent storage when
I
> create a new parent object?
> >>>
> >>>Example code:
> >>>    db.begin();
> >>>    Permission perm1 = new Permission( "perm1" );
> >>>    Permission perm2 = new Permission( "perm2" );
> >>>    Role role = new Role();
> >>>    role.add( perm1 );
> >>>    role.add( perm2 );
> >>>    db.create( role ); <------
> >>>    db.commit();
> >>>
> >>>Public methods:
> >>>    The class Permission has get/set Name and Id (String)
> >>>    Role also has get/set Name and Id (String), and get/set Permissions
> (Collection)
> >>>Relationships:
> >>>    The Permission class is not dependant on Role.
> >>>    There is a m:n relationship between the Role and Permission
classes.
> >>>
> >>>All works OK if I create the permissions first in persistence storage,
> using a UUID key-genarator (for both Permission and Role), then retrieve
the
> permissions from storage and add them to the role. Mapping between Role
and
> Permission works OK.
> >>>
> >>>However things don't work fine if I add new permissions to role without
> first creating them in the persistent storage. Is there a way I can get
> castor to do this without making  Permissions dependant on Role?
> >>>
> >>>Maybe castor can't do this yet?
> >>>
> >>>Any help is much appreciated.
> >>>Thanks,
> >>>Bert.
> >>>
> >>
> >
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to