Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

question about entity bean lifecycle

Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i am new to the EJB world, i created a sample entity bean which is accessed through a stateless session bean. it seems like everytime i called the findByPrimaryKey method on the entity bean, it created a new instance of the bean even i called findByPrimaryKey with exactly the same key. is it normal, or i did something wrong. coz, why does the container create new instance of the bean everytime instead of reusing the same instance to save memory? can somebody clear this out for me? thanks in advance.
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calling findByPrimaryKey results in the invocation of ejbFindByPrimaryKey, which returns the primary key type. This is not the same as a bean instance. The primary key maps to a either a single field or multiple fields in the entity bean class.
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic