Foreign Key « Delete « JPA Q&A





1. How to handle deletion of many JPA entities which has foreign key relationships    stackoverflow.com

Problem: Entities (say Users) are showed in a paginated fashion in the UI. The UI also shows a checkbox against each entity, so that it is possible for the admin to ...

2. hibernate cascading delete, why not one delete on the foreign key?    stackoverflow.com

I'm wondering why hibernate generates 1 delete per entity on a child table instead of using one delete on the foreign key Here's the hibernate.cfg.xml (No i's not the next SO :-t

<hibernate-configuration>
  ...

3. how can we use foreign key when deleting data in hibernate    stackoverflow.com

I have two tables which are refered by foreign key... I will delete the data from first table using primary key...and also i want to delete that refered data from second table ...

4. Foreign key on delete cascade using link table (one-to-one)    forum.hibernate.org

I need to have a link table that maps the ID of two classes that are persisted differently since they're used by two different programs. Class A is in the Java/JBoss/Javax/Hibernate domain while class B is used in the C++ domain and persisted by using DB access classes (class B is though realized on the Java side also in order for ...

5. cascading delete, why not one delete on the foreign key ?    forum.hibernate.org

I'm wondering why hibernate generates 1 delete per entity on a child table instead of using one delete on the foreign key Here's the hibernate.cfg.xml for this toy project Code: jdbc:hsqldb:file:testdb;shutdown=true org.hsqldb.jdbcDriver ...

6. Cannot delete or update a parent row: a foreign key...    forum.hibernate.org

Hi, I am trying to update an entity called EntityOne followed by a series of delete's on another entity called EntityTwo. EntityTwo has a FK to EntityOne. While I do this operation within a same session(Spring managed OpenSessionInView) I get: Quote: Cannot delete or update a parent row: a foreign key constraint fails 1. I first save EntityOne 2. I then ...

7. Many-to-many, foreign keys and delete    forum.hibernate.org

Newbie Joined: Tue Nov 18, 2003 11:56 am Posts: 16 I can't figure out how to set up the mapping for a many-to-many relation when the many table in my database has foreign keys. What I want is a many-to-many bidirectional relation between User and Role. The problem is that I get a exception (see below) with the message "Cannot delete ...

8. Database-side foreign key on delete/update cascade (etc)?    forum.hibernate.org

Hello all, I have been digging in the docs for a long time now and I don't think I have got a satisfactory answer to a question which at least to me seems rather basic and central... How well does Hibernate coexist with database-side "data-altering" foreign key constraints, say, an on delete cascade? I am building an app where the database ...

9. session.delete(parent), foreign key violated    forum.hibernate.org

Hi, I have a Parent class which has a one-to-many Set of Children defined in the hbm file. In the hbm file of the Child, there is NO many-to-one relationship, as I don't have the need for a bi-directional relationship. In the (Oracle) database, the child table has a not-null foreign key to the parent table, along with a cascading delete ...





10. Cascading delete with Foreign Key rel. among cascading items    forum.hibernate.org

We have a one-many relationship where the "many" items are dependent on each other, and we are using cascading delete to remove the "many" when the "one" is deleted. E.g. We have a Shape object with a set of Points. One point is the "referencePoint" for another point. If we delete the shape we want to cascade the delete to the ...

11. auto deletion of foreign key records when deleting record    forum.hibernate.org

Hi I am working with Hibernate 3.1 and have the following doubt: I have two tables, A and B. B holds a field with foreign key to table A. Is there a way to tell hibernate that when a request comes to delete a record from A, it will delete all records from B with the matching foreign key first? I ...

12. Problem with foreign-key / cascade delete with many-to-many    forum.hibernate.org

Hibernate version: 3.2.6.ga Hi, I have two classes with an unidirectional many-to-many relation, the relation is stored in a separate table: Code: ...

13. Delegate cascade delete on foreign key to underlying RDBMS?    forum.hibernate.org

Are you using hibernate core or annotations? I've been able to achieve this with annotations, using the @OnDelete annotation. I'm sure there's an equivalent in hbm mapping files. However, I did notice the following: In one-to-many, the @OnDelete was declared on the non-owning side of the relationship (i.e. the parent). For example, in a company-employee relationship, I declared it in company. ...

14. Bulk Delete with On Cascade Delete on DB Foreign Key    forum.hibernate.org

Hello, I use MySQL 5.0 and Hibernate Core 3.3.1.GA, Hibernate Tools 3.2.4 GA and Hibernate Annotation 3.4.0. My requirement is to be able to delete an Object tree without navigating it. Therefore I looked in the dml deletes in the documentation. Here is my query: Code: int dailyDataDeleted = getSession().createQuery("delete from DailyData as dbd where dbd.day between '2009-06-01' and '2009-06-05').executeUpdate(); My ...