Note that there are some explanatory texts on larger screens.

plurals
  1. PO@ManyToMany Referential integrity constraint violation ON DELETION
    text
    copied!<h2>@ManyToMany Referential integrity constraint violation ON DELETION</h2> <hr> <p>I got this manytomany relationship </p> <pre><code> @ManyToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER) @JoinTable( name="tbl_settings_employees", joinColumns = @JoinColumn(name = "id"), inverseJoinColumns = @JoinColumn( name = "employee_id") ) private Set&lt;Employee&gt; employeeSet; </code></pre> <p>which doesn't allow me to delete the primary object. with other words, i cant delete an employee from the database in my case.</p> <p>I got 4 tables for this example, a user table, a settings table a settings_edit_employee_set table and a employee table.</p> <p>These are the tables and the relations:</p> <pre><code>|---------| |----------------------------| | tbl_user| | tbl_settings | | --------| | ---------------------------| | Id (PK) | | Id (PK)| user_id (PK ref tbl_user) |---------| |----------------------------| | 1 | | 1 | 1 | | 2 | | 2 | 2 | | 3 | | 1 | 2 | | 4 | | 2 | 1 | | etc | |etc |etc | |---------| |----------------------------| |-------------------------------| | tbl_settings_employees (pk=composite) | ------------------------------| | Id (PK ref tbl_settings) | | | Employee_ID(PK ref tbl_employee) |-------------------------------| | 1 | 150 | | 1 | 149 | | 2 | 150 | | 2 | 151 | | etc | etc | |-------------------------------| |-------------| | tbl_employee| | ------------| | Id PK | |-------------| | 149 | | 150 | | 151 | | etc | |-------------| </code></pre> <p><strong>short:</strong> <br> I want to delete an object from my database but I can't right now; because it gives a Referential integrity constraint violation exception :</p> <pre><code>org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "FKE5EF0384FB556B15: PUBLIC.TBL_SETTINGS FOREIGN KEY(EMPLOYEE_EMPLOYEE_ID) REFERENCES PUBLIC.TBL_EMPLOYEE(EMPLOYEE_ID) (2)"; SQL statement: delete from tbl_employee where bsn='234234234' [23503-166] </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload