Can I set the data represented by the BMP Entity Bean to null in ejbStore, once it's updated in the database?

Dan Christopherson

[Question continues:
Every business method is always called after an ejbLoad. Therefore the bean has no reason to hold on to the memory for the data between an ejbStore and subsequent ejbLoad. This becomes important when such data is huge and the bean is accessed infrequently. ]

Theoretically, you could set your data to null after ejbStore, unless your container implements a caching optimization that skips ejbLoad in some cases (even then you could turn it off)

However, the purpose of the EJB specification is to allow application programmers (Bean Providers, in your case) to operate in blissful ignorance of resource and transaction management concerns. A well-written container will swap unused beans out if neccessary. In fact one instance of your entity bean implementation class might be used to represent one logical entity (say with primary key value '1234') in one transaction and another logical entity (primary key value '5678') in the next transaction a couple milliseconds later. Because of this, it is rather important that your ejbLoad method initialize all fields, to avoid side-effects.

Having said this, the real answer is "Go ahead, but don't worry about it unless 'huge data' means multi-megabyte stuff"
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact