This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes EntityExistsException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "EntityExistsException" Watch "EntityExistsException" New topic
Author

EntityExistsException

Tang Yue
Ranch Hand

Joined: Nov 11, 2008
Posts: 40
In persistance spec 3.7:
"
The EntityExistsException may thrown by the persistenc
operation is invoked and the entity already exists. The E
thrown when the persist operation is invoked, or the Enti
PersistenceException may be thrown at commit time. "

But in the study guide:
"
For a given entity A, the persist method behaves as follows:

If A is an existing MANAGED entity, it is IGNORED. However, the persist operation
cascades as defined below. "

Isn't the two contradictory? If one invokes persist(A) where A is a managed entity and surely already exists, will this persist() be ignored or an EntityExistsException be thrown?


Houston Rockets go go go!
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

"
The EntityExistsException may thrown by the persistenc
operation is invoked and the entity already exists. The E
thrown when the persist operation is invoked, or the Enti
PersistenceException may be thrown at commit time. "


Looks like you missed out some part of the sentence while posting it here Could you please edit your post to include the entire statement.


[My Blog] [JavaRanch Journal]
Tang Yue
Ranch Hand

Joined: Nov 11, 2008
Posts: 40
Oops, I paste the full text of that quote here:
"
EntityExistsException
The EntityExistsException may thrown by the persistence provider when the persist operation is invoked and the entity already exists. The EntityExistsException may be thrown when the persist operation is invoked, or the EntityExistsException or another PersistenceException may be thrown at commit time. "
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

Originally posted by Tang Yue:

The EntityExistsException may be thrown by the persistence provider when the persist operation is invoked and the entity already exists. The EntityExistsException may be thrown when the persist operation is invoked, or the EntityExistsException or another PersistenceException may be thrown at commit time. "


Since it says "may", I think its upto the persistence provider to decide whether to throw the exception or not.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EntityExistsException