users@glassfish.java.net

Re: How to enable Eager Loading for OneToOne and ManyToOne entity relations

From: <glassfish_at_javadesktop.org>
Date: Tue, 13 May 2008 12:16:52 PDT

hey chris, thanks for your reply.

i have logged all the queries like you proposed. you are right. if you have an entity A with a dependent entity B and you trigger this relationship in business tier and afterwards you pass entity A to web tier, then entity B can be accessed by accessing entity A in web tier.

but in my app, i have not triggered this relationship. so entity B shouldn´t be available in web tier. although it is available. i have found out that this behavior only occurs if you are using a local interface for the ejb method that retrieves entity A. in web tier, when you try to access entity B through entity A and entity B is not available, there will be a reconnection to the persistence provider and B will be fetched. that´s why FetchType.LAZY seems not to be working properly.

instead, when you are using a remote interface, the behavior is as expected: in web tier, B cannot be accessed by accessing A.
[Message sent by forum member 'zebhed' (zebhed)]

http://forums.java.net/jive/thread.jspa?messageID=274100