Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Manually delete entity bean in memory?

 
yik yang
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Other than reducing the entity bean pool size using admin console, is there any other way to manually delete the allocated entity bean from the memory?
I dont want to call ejbRemove bcos it will delete my actual record from database. What i want is after completed a certain functions, and i am pretty sure that the entity bean which i allocated in those functions are 100% no longer to be used and would like to free them from memory....
 
Pushkal Mishra
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
unsetEntityContext()
this is the best we can do. After that it is over to the container to garbage collect the object.
Please correct me if I am wrong.
Thanks,
Pushkal
 
yik yang
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but can we call unsetEntityContext() MANUALLY from session bean? I thought unsetEntityContext() is called AUTOMATICALLY by the ejb container?
 
Pushkal Mishra
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya you are right, it is invoked by the container only. My oversight!!
I don't know any other way. Let me know if you find something.
Pushkal
 
s basetti
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
before knowing that just call the method & see inside session bean..whether instance can be manually sent to the pool.
I guess EJBRemove() removes the instance & not from DB. Pls. call this as well from your session bean & see..
Pls. write your results here as well...
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess EJBRemove() removes the instance & not from DB

The db row is removed but not the bean form memory. You can manually delete a bean throw SystemException.
 
Vinod John
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by yik yang:
Other than reducing the entity bean pool size using admin console, is there any other way to manually delete the allocated entity bean from the memory?

Is there any particular reason you don't want to do this ?
Originally posted by Pradeep Bhat:

The db row is removed but not the bean form memory. You can manually delete a bean throw SystemException.

Actually the bean will be removed from the memory but the app server may replace it with another upon request, so the as long as the pool size mentions x beans there is a good chance x number will be mailtained in the mmemory.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the bean will be removed from the memory but the app server may replace it with another upon request

Are you talking about entity beans or session beans ? I am talking about entity beasn. When ejbRemove in entity bean is called the bean return to pool. Read page # 247 of spec.
 
Vinod John
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pradeep Bhat:

Are you talking about entity beans or session beans ? I am talking about entity beasn. When ejbRemove in entity bean is called the bean return to pool. Read page # 247 of spec.

My comment for about the "SystemException" not ejbRemove(). BTW, thanks for your spec reference but you missed the version ???
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic