|
I had this same problem. I'm wondering why this isn't the default
behavior of OJB?
When a new object is saved, all of the references need to be inserted, so
it doesn't matter what the collection is. After that, all work will be
against a materialized collection.
If this has been hashed out before please let me know. If you could
give me a topic to search on in the archives that would be great. Having this be
the default just makes sense or am I missing something?
Thanks,
Chris
>>> [EMAIL PROTECTED] 09/25/03 10:34AM >>> Hi can be it is a solution with you to see Add in Class-descriptor collection-class="org.apache.ojb.broker.util.collections.ManageableVecto r" -----Original Message----- From: Mart�n Capriotti APTIX [mailto:[EMAIL PROTECTED] Sent: jeudi 25 septembre 2003 17:02 To: [EMAIL PROTECTED] Subject: problem with n:m collection 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] |
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
