Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Entity Manager Remove Operation

 
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

According to the EntityManager interface documentation, the remove operation will throw an exception if the passed entity reference is a detached entity.


@throws IllegalArgumentException if not an entity
* or if a detached entity

public void remove(Object entity);



The find and getReference methods will return a detatched entity, also mentioned in the EntityManager documentaion if invoked in a transaction scoped entity manager.

My question is Can I remove an entity using the remove method in a transaction scoped entity manager.

Thanks in advance.
 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm not skilled at all about scbcd5, but it seems to me that the paragraph of the specification speaks about the requirement to invoke getReference/find inside a transaction: you are not required to call find/getReference inside a transaction, and, in case of transaction-type persistence context, out of a transaction all the objects are detached.

Hope this helps...
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I think what is meant by "The resulting entity will be detached"
is when the transaction ends. But during the transaction, the
returned entity reference is still managed.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic