I have been trying to get a new project off the ground using These technologies:
I would like to utilize the OneToOne and OneToMany lazy loading. I have everything setup correctly, as I am not getting any errors at all. However, I never get my entities woven but I see this in the logs for my @Entities:
When I access my @Entity that has these mappings, I get this in the logs:registered to be processed by weaver.
I have the <Loader> tag in my context.xml that Tomcat is picking up, along with my JNDI properties. I have the tag <context:load-time-weaver /> in my spring configuration file. I am also taking advantage of the new Spring 3.1 feature that enables me to NOT use a persistence.xml, however one is defined so I can generate my Meta Model classes.Reverting the lazy setting on the OneToOne or ManyToOne attribute [(fieldInClass)] for the entity class [class (registered @Entity class] since weaving was not enabled or did not occur.
Like I have said, everything EXCEPT weaving is happening properly; and thus lazy OneToOne associations are not working. Weaving is TRYING to work, as it goes over all the classes defined correctly; as i can persist and find just fine. The problem seems to be that the classloader tries to weave the classes before Spring has been able to define the Application Context, so no ClassFileTransformer's are ever defined. When Spring starts up and initializes the SpringPersistenceUnitInfo and delegates the EclipseLink weaver we get the needed ClassTransformer added. This all happens AFTER the TomcatInstrumentableClassLoader has called findResourceInternal() and tried to weave my POJO's.
So the problem seems to be the fact that LTW means we weave when the class gets loaded. The class loader loads the class and attempts weaving, when we actually have a transformer that would do the job the classes are already loaded and so not weaved.
Not sure what the fix for this would be, but it would be nice to be able to utilize this functionality. I would think that we would have to ensure we have added a transformer before being able to attempt the weaving. I agree this still needs to only happen once and at the first load, but getting the right transformer BEFORE we try to transform is a critical part to ensuring the weaving happens correctly.
If there is a work around that I have not found please let me know, if this is a bug I can file a bug report but wanted to hit the forums first.
I suppose since there hasn't been any comments on this post I will move forward with submitting a bug to spring. Well, I'll wait a few days first and will update this post with the bug ticket number. At this point lazy loading a OneToOne is impossible with Spring 3.1 and EclipseLink 2.3.2.
EDITED: Created this Spring JPA ticket, hopefully we can get this squared away for a future release or find a work around. https://jira.springsource.org/browse/DATAJPA-157