• Post Reply Bookmark Topic Watch Topic
  • New Topic

Entity Bean Caching

 
Vels Manian
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm using entity beans in my project, but we identified a peculiar problem in create methods. we have two create methods in a bean, one method inserts record with data in all the columns of the table and the other inserts with only mandatory fields. But if the method with all columns is called first from a session bean and then the second method is called from a different session bean.. the data of the old method gets inserted with this record..
We have a found work around for this problem. we have written a method resetValues().. which initializes all variables in the bean. All create methods calls this method and then sets value in the variables. This fix works, but we cant implement the strategy in all the beans.
We are using Websphere 3.5. Please help me to solve this problem.
Regards
Vels
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not a problem peculiar to WebSphere. When a bean is returned to the ready pool its variables are not guaranteed to be cleared out. The spec is silent on this. Instead, it's a best practice to set the values of ALL instance variables in your ejbCreate() methods, even if you set them to nil (as you would your non-mandatory fields).
Kyle
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a feature... not a bug.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!