[ https://issues.apache.org/jira/browse/DELTASPIKE-701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14542322#comment-14542322 ]
Rafael Benevides commented on DELTASPIKE-701: --------------------------------------------- Patch reviewed. It's good to go!!!! > Add method in EntityRepository to merge a detached entity and remove it > ----------------------------------------------------------------------- > > Key: DELTASPIKE-701 > URL: https://issues.apache.org/jira/browse/DELTASPIKE-701 > Project: DeltaSpike > Issue Type: Improvement > Components: Data-Module > Reporter: Juliano Marques > Assignee: Thomas Hug > Attachments: DELTASPIKE-701.patch > > > It will be nice if EntityRepository has a method like: > public void attachAndRemove(Entity entity) { > if (entityManager.contains(entity)) { > entityManager.remove(entity); > } else { > entityManager.remove(entityManager.merge(entity)); > } > } > This method will be useful to handle "java.lang.IllegalArgumentException: > Removing a detached instance" exceptions. > Workaround: Create a query delegate with this method. > http://mail-archives.apache.org/mod_mbox/deltaspike-users/201408.mbox/%3CCAAuOd%3DXhb%3D-ssdzU%3DTdxWg8d18XXC15U7EjNiGya9eEgaA%2BUpA%40mail.gmail.com%3E -- This message was sent by Atlassian JIRA (v6.3.4#6332)