Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » unable to get lazy loading to work(spring2.5.6/eclipselink2.0/tomcat5.5/maven2.2.1)
icon9.gif  unable to get lazy loading to work [message #505774] Mon, 04 January 2010 16:37 Go to next message
Eclipse UserFriend
we are trying to get lazy loading to work, using this environment:

spring 2.5.6
eclipselink 2.0
maven 2.2.1
tomcat 5.5 (or tomcat6)
mysql 5.0.83

from one of the tutorials on eclipselink, we learned that dynamic weaving is not available in tomcat. ok. static weaving it is then.

we learned from this article ( http:// www.tzavellas.com/techblog/2008/10/17/statically-weaving-jpa -entities-for-eclipselink-using-maven/ ) how to statically weave our jpa entities.

when maven runs, it looks like static weaving is happening, for example, we see output like this:

[java] [EL Finest]: 2010-01-04 13:40:04.765--ServerSession(18378667)--Thread(Thread[main,5, main])--Begin weaver class transformer proce
ssing class [com/aftama/core/db/entity/Tenant].
[java] [EL Finest]: 2010-01-04 13:40:04.781--ServerSession(18378667)--Thread(Thread[main,5, main])--Weaved fetch groups (FetchGroupTrack
er) [com/aftama/core/db/entity/Tenant].
[java] [EL Finest]: 2010-01-04 13:40:04.781--ServerSession(18378667)--Thread(Thread[main,5, main])--End weaver class transformer process
ing class [com/aftama/core/db/entity/Tenant].

In the Tenant entity, shown in the above log output, we have one-to-many relationships defined like so:

@OneToMany(mappedBy = "tenant", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<MediaCategory> mediaCategories = new ArrayList<MediaCategory>();

we have this line in our persistence.xml:

<property name="eclipselink.weaving" value="static" />

when we invoke a service call to fetch a Tenant (from a flex/blazeds UI to tomcat), it eagerly fetches the oneToMany collection, described above. we are expecting it not to fetch it, so that when we get the Tenant object back, the collection is null or empty.

we tried this in tomcat5 and tomcat6, with the same result: the oneToMany collection is fetched rather than not fetched.

what are we missing? how do we get lazy loading to work in this environment?

Re: unable to get lazy loading to work [message #505911 is a reply to message #505774] Tue, 05 January 2010 04:56 Go to previous messageGo to next message
Eclipse UserFriend
Actually weaving is only required for lazy OneToOne/ManyToOne lazy will work in OneToMany without weaving.

So something in your model or application is most likely instantiating the relationship. Check that you are not accessing it. Also make sure you are not using a join fetch on it, if you don't want it instantiated.

Re: unable to get lazy loading to work [message #506045 is a reply to message #505911] Tue, 05 January 2010 15:45 Go to previous messageGo to next message
Eclipse UserFriend
james,
thank you for the reply. you were correct; it turns out the java layer is correctly lazy-loading the oneToMany relationships. it turns out that the Blazeds serialization was causing the problem. from the blazeds documentation: "during serialization, the serializer eagerly fetches all the jpa persistent objects and sends them across the wire."

so now the question for us is: we need a blazeds adapter to intercede the eager serialization. there is dpHibernate that works out of the box; but seems to only work with Hibernate, not Eclipselink. we'd rather not try to develop our own. Does anyone know of a solution (adapter) for integrating Blazeds and Eclipselink for lazy loading? Is anyone else out there doing this?
Re: unable to get lazy loading to work [message #538316 is a reply to message #505774] Mon, 07 June 2010 06:36 Go to previous message
Eclipse UserFriend
I need a big help to solve this huge performance issue .

Project description
use eclipseLink JPA 2.0
spring 3.0.1 web 3.0.2 security
front end flex
spring blazeDS Integration

Issue

When I call to one spring service from client flex app,
JPA will loading the table that I need and all the tables that have relations to the table even I have declared it JPA lazy loading also.
Previous Topic:jpql query mystery
Next Topic:Storing empty strings in an oracle database
Goto Forum:
  


Current Time: Wed Jul 02 16:59:16 EDT 2025

Powered by FUDForum. Page generated in 0.03787 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top