During a cascade remove in JPA I'm seeing 'Unable to find <entity> with id <id>'

Solution Verified - Updated -

Issue

  • While trying to launch a remove() command on a table entity, the CascadeType.REMOVE property associated to the link might have tried to delete the entities from other linked tables. However, although the links references looks correct in term of architecture and values, an EJBTransactionRolledbackException exception is thrown with label "Unable to find ...MyEntity with id 290". Apparently the id used to delete the MyEntity is the id of the parent entity.
  • The problem seems to be the same when trying to get the containers collection from the parent. Changing the fetching mode to EAGER has no impact. In lazy fetching mode, to get the collection hibernate made several requests :

    • one to get the sorting wave.

    • one to get the containers input with the join column using the sorting wave primary key.

    • And one request per container to retrieve the entire container data. The error happens during the first request of the third step.
  • The entities on which this problem occurs are the following :

Environment

  • Enterprise Application Platform (EAP)
    • 4.3.0 CP06
  • Java Persistence API (JPA)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.