users@glassfish.java.net

Toplink not cascad deleted OneToMany objects when merge() called

From: <glassfish_at_javadesktop.org>
Date: Tue, 12 Feb 2008 23:12:43 PST

Permission.java
.....
@OneToMany(cascade = CascadeType.ALL, mappedBy = "permission")
   private Collection<UnloadPort> unloadPortCollection;
//=====================
UnloadPort.java
....
   @JoinColumns({_at_JoinColumn(name = "serial", referencedColumnName = "serial", insertable = false, updatable = false), @JoinColumn(name = "number", referencedColumnName = "number", insertable = false, updatable = false)})
   @ManyToOne
   private Permission permission;
//======================

Code:
 public persist(Object object)
{
      EntityManager em = rcbp.createEntityManager();
       try
      {
         em.getTransaction().begin();
         em.merge(object);
         em.getTransaction().commit();
      } catch (Exception e){...}
...
Permission permission = em.find(Permission.class,PermissionPKinstance);
permission.getUnloadPortCollection().remove(port1);
permission.getUnloadPortCollection().remove(port2);
persist(permission);

But in table UnloadPort rows for port1 and port2 not deleted

When i try

Permission permission = em.find(Permission.class,PermissionPKinstance);
permission.getUnloadPortCollection().add(port3);
permission.getUnloadPortCollection().add(port4);
persist(permission);

this work and in table rows for port3 and port4 normaly inserted

anybody help me and say what i must do
to cascade update relationship table UnloadPort
[Message sent by forum member 'bochkov2006' (bochkov2006)]

http://forums.java.net/jive/thread.jspa?messageID=258655