[jira] [Commented] (DELTASPIKE-701) Add method in EntityRepository to merge a detached entity and remove it
[ https://issues.apache.org/jira/browse/DELTASPIKE-701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14577347#comment-14577347 ] Rafael Benevides commented on DELTASPIKE-701: - Thanks [~danielsoro] > 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)
[jira] [Commented] (DELTASPIKE-701) Add method in EntityRepository to merge a detached entity and remove it
[ https://issues.apache.org/jira/browse/DELTASPIKE-701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14577325#comment-14577325 ] Daniel Cunha (soro) commented on DELTASPIKE-701: Thanks [~thomashug] and [~rafabene]. I'll apply later. > 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)
[jira] [Commented] (DELTASPIKE-701) Add method in EntityRepository to merge a detached entity and remove it
[ https://issues.apache.org/jira/browse/DELTASPIKE-701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14577283#comment-14577283 ] Thomas Hug commented on DELTASPIKE-701: --- Looks good to me too. > 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)
[jira] [Commented] (DELTASPIKE-701) Add method in EntityRepository to merge a detached entity and remove it
[ 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)
[jira] [Commented] (DELTASPIKE-701) Add method in EntityRepository to merge a detached entity and remove it
[ https://issues.apache.org/jira/browse/DELTASPIKE-701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14542299#comment-14542299 ] Daniel Cunha (soro) commented on DELTASPIKE-701: Patch attached. :) > 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)
[jira] [Commented] (DELTASPIKE-701) Add method in EntityRepository to merge a detached entity and remove it
[ https://issues.apache.org/jira/browse/DELTASPIKE-701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14188547#comment-14188547 ] Denis Falqueto commented on DELTASPIKE-701: --- I would like to propose a subtle change in the implementation: public void attachAndRemove(Entity entity) { // Entity is detached so perform a merge before removing. if (!entityManager.contains(entity)) entity = entityManager.merge(entity); } entityManager.remove(entity); } It's just a simpler code path. > 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 > > 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)