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

Error in MZ notes - EntityManager.find

 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is about the EntityManager.find method.

According to the MZ notes:
MZ Notes wrote:If the instance is already present in the current persistence context, the cached version will be returned. Otherwise, a new instance will be constructed and loaded with state from the datastore.



But the "Pro EJB 3" book says
Pro EJB 3 wrote:In the event that the object was not found, then the find() call simply returns null. We would need to ensure that a null check is performed before the next time the emp variable is used.



I think that this is an error with Maikali Zaikin's notes. Am I correct?
 
Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MZ notes say about a case when the entity was not in the first-level cache (was not managed).
The book says about a case when the entity with the specified key was not found in the cache, and also could not be found in the database.
 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raf Szczypiorski wrote:MZ notes say about a case when the entity was not in the first-level cache (was not managed).
The book says about a case when the entity with the specified key was not found in the cache, and also could not be found in the database.


Oh! Thanks. I understood.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic