[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Deleting one side of a ManyToMany

apinto do-not-reply at jboss.com
Thu Mar 27 11:38:20 EDT 2008

Hi there!

I have a ManyToMany relation between ClassA and ClassB, defined in the following way:


  | @ManyToMany
  | @JoinTable(name="a_b",
  | 	joinColumns=@JoinColumn(name="aid", referencedColumnName="id"),
  | 	inverseJoinColumns=@JoinColumn(name="bid", referencedColumnName="id"))
  | public Set<ClassBBean> getMyBs()


  | @ManyToMany(mappedBy="myBs")
  | public Set<ClassABean> getMyAs()

The problem is that when I try to delete a ClassB entity, it fails with the violation if an integrity constraint (child record found). If I put a CascadeType.ALL in the ClassB definition, it deletes the corresponding ClassA entity, even if it has other associations... What I want is to just delete de ClassB entity!

Can anyone help me? What am I missing? Thanks a lot in advance,


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4139346#4139346

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4139346

More information about the jboss-user mailing list