Originally posted by Rahul JG:
In an Entity Bean, if a finder method returns a large number of records (say
thousands of them), will thousand bean instances be created? If yes, what
happens if the number of bean instances required to be created exceed the
number of instances which have been specified to be maintained in the pool?
I know this question would have been asked many times in many forums, but I
haven't been able to get a convincing reply. Can anyone answer me?
IMHO: If the pool is big enough and you have enough memory and there is only one active session, I guess it could load everything (unless it uses lazy loading).
But even if the pool is big enough and all the instances would fit in the ammount of memory you have, some of your beans may still be discarded (not loaded) since the container may need to load other beans or it may choose not to discard another bean in order to be able to load yours.
Since you're not accessing your beans all at once, the container can swap it quite nicely. But exactly how all this happens is very implementation dependent.
Keep in mind that in a real world scenario you may have multiple sessions accessing sets of beans in the container. it depends on your app's design, on the user's behavior, on the number of users and mostly on the algorithm the container implements.
Also, consider that the user may interact with your application is a very ramdom way.
Given all these parameters, I don't think it is possible to predict how your beans will be loaded / discarded.
Cheers,
e.