This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Section 3.2.1 of EJB 3.0 Persistence Specs  RSS feed

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Got a question.
Hope anyone can help me.

Under Section 3.2.1 (Persisting an Entity Instance) of EJB 3.0 Persistence Specs, it says

"If X is a detached object, the EntityExistsException may be thrown when the persist
operation is invoked, or the EntityExistsException or another PersistenceException
may be thrown at flush or commit time."


My understanding is that the "persist" method is for persisting a detached entity.
Why then will the "EntityExistsException" be thrown?

Please help!
Thanks!
 
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

My understanding is that the "persist" method is for persisting a detached entity.
Why then will the "EntityExistsException" be thrown?


Wouldn't you use "merge" instead ?
 
Meng Tan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Christophe,

Yes, to save a detached entity, a "merge" can be used.

But Section 3.2.1 is for the "persist" operation.
It gives the semantics of the operation when performed with a new, preexisting managed, removed and detached entity.

Why is a "detached" entity considered differently from a "new" entity?

Thanks!
 
Meng Tan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I have missed the definitions of "new" and "detached" entities early in section 3.2.

A detached entity represents a record that is already in the database but the entity object itself is not associated with any persistence context.

Thanks!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!