• Post Reply Bookmark Topic Watch Topic
  • New Topic

Confused on how stateful EJBs work  RSS feed

 
Nehaa Verma
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am very new to EJBs. I just have a doubt as to, is there a primary key in Stateful EJBs that is used to find out if if an instance exists or not for a particular session. As far as my understanding goes, stateful session beans are associated with sessions. But how does the server know which instance is a session bound it.

Why I am asking all this , is because, I have a method that calls the create of session bean on every page load.passign the same parameter yo hetEJBHome everytime. Now the problem is, after eveery page refresh, a new session bean is formed ans soon the cache is full and it gives a cache full exception. I have the code right below.

Could someone please tell me where my undretsnaing is wronng


---------------
WorklistHome wkhome =(WorklistHome)(ServiceLocator.getInstance().
getEJBHome(contextKEY, providerURL,userID, password, "com.bea.wlpi.Worklist", WorklistHome.class));
worklist = (Worklist) wkhome.create();
-----------------------

What I want to do is, before I call the create method, I want to do a find on wheather an instane exists fir that session and call create only when an instance is not present for that session. Is there a method to do that?
Thnaks a lot
 
KEvin Runion
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can store the bean reference in your http session. Then pull it back out when you need it. Only create the bean when the user first signs in or as needed if it doesnt exist; depending on how your system works.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!