Greetings,
I have a doubt: what happens if a session bean returns a lazily initialized persistent entity? Are the lazy collections readable?
I have three cases:
1. A stateless session bean invoked by a
servlet 2. A stateful session bean invoked by a servlet
3. An inner stateless session bean (local interface) invoked by a session bean
4. An inner stateful session bean (local interface) invoked by a session bean
I have tried the four cases:
1. RuntimeException: no session
2. RuntimeException: no session
3. Ok
4. Ok
Well, I collected the following conclusions, respectively:
1, 2. A remote method returns Objects by copy. Moreover, if the persistence context is transaction type, the returned object is returned as detached
3, 4. Inner session bean share the same injected persistence context. Moreover, local interfaces return objects by reference.
Is all right?
But, if an inner session bean (cases 3, 4) has a transaction persistence context injected, it should always return disconnected objects, but it does not seem to be true: in fact, in cases 3, 4 the object returned by the inner session bean has readable lazy collections.
Can you help me understand? Thanks !