hibernate - Deleting JPA entity containing @CollectionOfElements throws ConstraintViolationException -


I am trying to remove entities in which there is a list of integers, and I am getting constraintiolation exception due to the foreign key. It is possible that the table generated for the integer appears to be cascading in the mapped mapped collection.

I have done a lot of research, but in the way I have seen the examples I have seen, a mapped collection of other institutions can be annotated; Here I am storing a list of integers.

  @Entity @Table (name = "CHANGE_IDS") @GenericGenerator (name = "CHANGE_ID_GEN", strategy = "org.hibernate: Here Class I is the relevant excerpt from'm storage. Id KenhancedkSequenceStyleGenerator "parameter = {@Parameter (name =" sequence_name ", value =" course_changes_seq "), @Parameter (name =" increment_size ", value =" 5000 "), @Parameter (name =" adapter " value = "submit")}) @NamedQueries ({@NamedQuery (name = "ChangeskgetByStatus", query = "where DChanges c" + "to select c" + "of c.status =: Condition"), @ NamedQuery (name = "Changes.deleteByStatus", query = "delete" + "c from change" + "ou c.status =: condition")}) public class change {@Id @GeneratedValue (generator = "CHANGE_ID_GEN") @Column (name = "id") private last long ID; @Enumerated (EnumType.STRING) @column (name = "condition", length = 20, faucet = incorrect) Personal last position status; @Column (name = From "DOC_ID") @ org.hibernate.annotations.CollectionOfElements @ org.hibernate.annotations.IndexColumn (name = "DOC_ID_ORDER") private List & lt; Integer & gt; DocIds; }  

I'm deleting change objects using @NamedQuery:

  Last query deleteQuery = this.entityManager.createNamedQuery ( "Changes.deleteByStatus" ); DeleteQuery.setParameter ("Status", Status.POST_FLIP); Last int delete = Delivere Execution Update (); This.logger.info ("Deleted" + Deleted + "POST_FLIP Changes");  

Delete an HQL related to entities according to JPA glasses ( However some users want to have extended behavior as reported). From the JPA 1.0 specification:

4.10 Bulk Update and Delete Operations

(...)

A deleted operation only specified class and its subclass It does not cascade for related institutions.

(...)

Then you are self while using bulk deletion.

However, in the special case of CollectionOfElements , there are no institutions (and since there is no way to remove bulk for collection), I was expecting to do the following work:

  @Column (name = "DOC_ID") @ org.hibernate.annotations.CollectionOfElements @ org.hibernate.annotations.IndexColumn (name = "DOC_ID_ORDER") @OnDelete (action = OnDeleteAction.CASCADE ) Private list & lt; Integer & gt; DocIds;  

But unfortunately, it is not, sessionfind complains on it:

  org.hibernate.MappingException: only According to the reverse one, many organizations can use "delete =" cascade "at: com.stackoverflow.q3049451.Changes.docIds  

According to one, it looks like a bug. ..

Then it leaves you with the solution implemented by you: Remove a selection, loop and entities.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -