Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Entity Bean finder method. Is this code silly?  RSS feed

 
Ted Bell
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this a waste of resources here? This code is called from a session bean, getting a list of orders from an entity bean. This snipit is from a private method which returns a list of orders. It seems to me this would do double work. I understand that the container may do some caching of the entity references themselves, but won't this go to the DB a second time?



Thanks.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if the container would actually cache the result, there's no good reason to rely on such behavior.
I would definitely prefer something like
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!