i have an instance variable in a BMP Entity Bean which is not mapped to any Persistent storage or not mapped to the database so when i assign some value to it in one of the finder method and then call the corresponding accessor(get) method i lose its value. i see in the server the passivation and activation being called is this the reason behind this, is there any solution for this.
An EntityBean is a representation of persistent data, so if you have state objects, which are not persistent, an EntityBean is the wrong choice. Then you have to use a stateful session bean.
ur right in that context,but i have a entity bean (BMP) whose instance variables are mapped to persistent storage, but apart from that i have an instance variable which is basically used as counter and whose value gets populated in one of the finder method and whose value gets lost when an accessor method is called,but logically speaking entity bean variables are not serialized they are just pooled and bought back to ready state so why is that iam losing that value, i think this might be because of passivation and activation being called, so what do u think??
any how thanks for the reply
From the point of theory the following happens: after each transaction the entity bean instance is passivated from ready state to the pool, so here ejbStore is called by the container and the entity bean instance is decoupled from its primary key object. If your ejbStore doesn't save the non persistent state, it is lost.
The population of the bean's variables has to take place in the ejbLoad method and not in the finder, because the finder methods are computed on pooled beans.
As a little bit "dirty" workaround you can store the counter value in a primary key object in addition to your primary key in the finder method. Then you could populate the instance variable in the ejbLoad method with the value stored in the primary key class, which you can get from the entity context.
Hope it helps
the answer was what we used but we want a right way to do it like any way can i control the activation and passivation what may be the problem behind it.