0 Replies Latest reply on Nov 26, 2003 7:43 PM by benstarr

    Cascade delete in container or database schema?

    benstarr Newbie

      I am creating a database schema which I want to map EJB CMP Entity Beans onto. There are a number of relationships in the schema where I want to cascade deletion if a parent record is deleted and a number of relationships where I want to prevent deletion of parent records if child records exist for the relationship.

      I am wondering whether it is better to implement this in the database schema (Oracle) or in the container (JBoss 3.2.2)? I believe it is possible to implement cascading delete in the container but I am not sure about preventing delete in the container? Is there a way I could do it programmatically? I want to use CMP though so I'm not sure there would be much scope for that.

      Are there any rules as to which approach is better? Will the container have a problem if I implement it in the database schema? Obviously the ejbRemove may throw an exception if I prevent deletion in a relationship but that is fine. I believe it is not a good idea to implement it in both the container and schema as there will be a conflict when they both try to delete records.