Christoph Hermann schrieb: Hello,
> i really need help with a Cforms binding which i can't get to work.
> I have two classes (User, Right) which have an m:n relation.
> <fb:on-delete-row>
> <fb:delete-node />
> </fb:on-delete-row>
Maybe someone can tell me what happens when delete-node is executed?
I presume it takes the id value and deletes the corresponding object
(Right)?
What i would need is that only the item in the Collection (User.rights)
is deleted, and not the corresponding right (I think this causes the
problem).
> Inserting new Rights works fine, hte problem is that when i change a
> right the old value is deleted from the Rights Table instead of only
> deleting the entry in the reference table.
> Can anyone of you help me how out on how an m:n relationship should
> be binded?
My repository.xml (I use ojb/jdo) looks like this:
<class-descriptor class="papillon.User" table="users">
<field-descriptor name="id" primarykey="true"
nullable="false" default-fetch="true" autoincrement="true" column="id"
sequence-name="users_id_seq" jdbc-type="INTEGER"/>
<field-descriptor name="nick" nullable="false"
default-fetch="true" column="nick" jdbc-type="VARCHAR"/>
<field-descriptor name="firstname" nullable="false"
default-fetch="true" column="firstname" jdbc-type="VARCHAR"/>
<field-descriptor name="lastname" nullable="false"
default-fetch="true" column="lastname" jdbc-type="VARCHAR"/>
<field-descriptor name="email" nullable="false"
default-fetch="true" column="email" jdbc-type="VARCHAR"/>
<field-descriptor name="pass" nullable="false"
default-fetch="true" column="pass" jdbc-type="VARCHAR"/>
<collection-descriptor name="rights"
element-class-ref="papillon.Right" auto-retrieve="true"
auto-update="link" auto-delete="link"
indirection-table="rel_users_rights" otm-dependent="false">
<fk-pointing-to-this-class column="users_id"/>
<fk-pointing-to-element-class
column="rights_id"/>
</collection-descriptor>
</class-descriptor>
<class-descriptor class="papillon.Right" table="rights">
<field-descriptor name="id" primarykey="true"
nullable="false" default-fetch="true" autoincrement="true" column="id"
sequence-name="rights_id_seq" jdbc-type="INTEGER"/>
<field-descriptor name="name" nullable="false"
default-fetch="true" column="name" jdbc-type="VARCHAR"/>
<collection-descriptor name="users"
element-class-ref="papillon.User" auto-retrieve="true"
auto-update="link" auto-delete="link"
indirection-table="rel_users_rights" otm-dependent="false">
<fk-pointing-to-this-class column="rights_id"/>
<fk-pointing-to-element-class
column="users_id"/>
</collection-descriptor>
</class-descriptor>
As you can see i specified there auto-update="link" etc... according to:
Mapping m:n associations
http://db.apache.org/ojb/docu/guides/basic-technique.html#m-to-n
> I wrote a flowscript to test if my classes are ok and this is working
> fine:
> user = new Packages.papillon.User();
> user.setId(15);
> user = dao.retrieve(user);
> firstname = user.getFirstName();
> right = new Packages.papillon.Right();
> right.setId(64);
> rights = new Packages.java.util.ArrayList();
> rights.add(right);
> user.setRights(rights);
> dao.update(user);
Here i just set new Rights, no Rights are deleted/removed from the
Collection i think this is the difference.
Can someone tell me how to reproduce this behaviour with Cforms?
My "workaround" would be not to use a binding or not to call
form.save(bean); then get the values out of the form in the flowscript
set them to the bean (bean.setXY(value)) and then save the bean. But i
don't think this is a good solution.
If you need more Information tell me please.
Christoph
pgpuEtq0U8vhp.pgp
Description: PGP signature
