This is because the default behavior was recently changed; collections now use
RemovalAwareCollection by default, which has the effect of deleting the
contained object as well as the relationship. The fix is to specify a different
ManageableCollection implementation in the collection-class attribute of your
collection-descriptor.
Because this surprising and fundamental change in behavior has been made at such
a late date (RC3 or 4?), it seems that it should be noted in the release notes
and perhaps added to the FAQ.
-steve
Steve Clark
Technology Applications Team
Natural Resources Research Center/USGS
[EMAIL PROTECTED]
(970)226-9291
>List-Id: "OJB Users List" <ojb-user.db.apache.org>
>From: Mart�n Capriotti APTIX <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Subject: problem with n:m collection
>Date: Thu, 25 Sep 2003 12:01:45 -0300
>X-Scanned-By: MIMEDefang 2.32 (www . roaringpenguin . com / mimedefang)
>
>Hi
>I have problems with n:m mappings, it is deleting the referenced objets instead
of deleting only the reference (when I delete it from the collection)
>(behaving as if auto-delete="true" is set)
>
>
>Example:
>one way n:m direct mapping from Roles to Usuario (nothing mapped from Usuario
to Rol)
>
>-------------------- MAPPING OF COLLECTION usuarios IN CLASS Rol
----------------------------------
><class-descriptor ... Rol...>
>...
><collection-descriptor
> name="usuarios"
> element-class-ref="net.aptix.intranet.seguridad.Usuario"
> indirection-table="ROLES_USR" >
> <fk-pointing-to-this-class column="ID_ROL"/>
> <fk-pointing-to-element-class column="ID_USR"/>
>
></collection-descriptor>
>
>-------------class Rol----------------------
>
>
>.....
>
>public Collection usuarios = new Vector();
>
>.....
>
>public Collection getUsuarios() {
>
>return usuarios;
>
>}
>
>public void setUsuarios(Collection _usuarios){
>
>this.usuarios=_usuarios;
>
>}
>
>-----------------------------------
>
>This example should remove one Usuario (id=5) from a Rol (id=10):
>
>Rol r=Rol.getRolById(10);
>
>Usuario u= Usuario.getUsuariobyId(5);
>
>r.getUsuarios.remove(u);
>
>store...
>
>----------------------------------------------------------------------
>
>It does the work.. and more: It removes Usuario "u" from the collection as it
should, but it also removes that object Usuario (id=5) from DB, as if
auto-delete="true" has been set!
>
>It seems this problem started when we moved from OJB 0.97 to 1RC4
>
>Thanks , Mart�n.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]