Note that there are some explanatory texts on larger screens.

plurals
  1. POJPA: constraints violation on delete
    primarykey
    data
    text
    <p>I have three entities -</p> <pre><code>public class ApplicationEntity extends ModelEntity implements Application { @ManyToOne(fetch = FetchType.LAZY, optional = false, cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) private CategoryEntity category; @ManyToMany(fetch = FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) @JoinTable( joinColumns = {@JoinColumn(name = "APPLICATION_ID")}, inverseJoinColumns = {@JoinColumn(name = "USER_ID")}, uniqueConstraints = {@UniqueConstraint(columnNames = {"APPLICATION_ID", "USER_ID"}) }) private List&lt;UserEntity&gt; buyers = new ArrayList&lt;UserEntity&gt;();} public class CategoryEntity extends ModelEntity implements Category { @Column(nullable = false) private String name; @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) private List&lt;ApplicationEntity&gt; applications = new ArrayList&lt;ApplicationEntity&gt;(); } public class UserEntity extends AbstractEntity implements User { } </code></pre> <p>When I try to delete AppliationEntity, I get a constraints violation exception. I tried to remove application entry from CategoryEntity, and then delete the ApplicationEntity. But still fails. The exception is something like --</p> <pre><code> Caused by: java.sql.SQLException: DELETE on table 'APPLICATIONENTITY' caused a violation of foreign key constraint 'FK109DF15D362F642' for key (32779). The statement has been rolled back. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source) ... 61 more Caused by: ERROR 23503: DELETE on table 'APPLICATIONENTITY' caused a violation of foreign key constraint 'FK109DF15D362F642' for key (32779). The statement has been rolled back. </code></pre> <p>Any suggestion is highly appreciated. Thanks in Advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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