2 Replies Latest reply on Nov 7, 2007 5:39 AM by Ignacio de Cordoba

    BatchUpdateException when removing a entity with a ManyToMan

    Ignacio de Cordoba Novice

      Hi there,
      I am getting BatchUpdateException when removing entities related to others by a ManyToMany association. Hibernate creates the link table with foreign keys and they make that BatchUpdateException to be thrown (I like tables to have foreign keys, of course).
      I've tried to add a REMOVE cascade, but that makes the end entity to be also removed (for example, removing a UserRole entity removes related User, while only should remove the entry in the intermediate link table.
      My question is... do I have to remove that relation in target entities before removing the related entity or there is a way to make JBoss/Hibernate to do some intermediate table cascading to remove the relation and avoiding BatchUpdateException?

      Thanks for any idea,