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

Reply via email to