Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ObjectNotFoundException Vs NoSuchEntityException

 
TeGo Gokhale
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ObjectNotFoundException: thrown when no entity in database matching primary key is found.
NoSuchEntityException: Thrown entity your are trying to access is no longer in database.

What is the difference??

Though one is checked and other is not but given a scenario only one can be thrown.
 
vidya sagar
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ObjectNotFoundException: Till now no entity in database matching primary key is exists in database

NoSuchEntityException: presently that entity is deleted,previsouly it will be in database

Correct me if i am wrong
 
Balaji Anand
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ObjectNotFoundException : this one is a finder exception. like when u use the find<method> and if the entity doesnt exist in the DB this exception or FinderException is got.

NoSuchEntityException this will be trown mostly from ejbLoad , ejbStore and from the methods that implement the business methods defined in the component interface when the entity being accessed is removed from the underlying store(ie after the entity has been found by the finder or created new, we have the ref to the entity already). The container may also throw NoSuchObject[Local]Exception to give a better idea to the client.


hope this helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic