Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink 2.1.1 / Problem with @ManyToOne(fetch = FetchType.LAZY)(EclipseLink 2.1.1 / Problem with @ManyToOne(fetch = FetchType.LAZY))
EclipseLink 2.1.1 / Problem with @ManyToOne(fetch = FetchType.LAZY) [message #631242] Wed, 06 October 2010 16:26 Go to next message
Martin Weiss is currently offline Martin WeissFriend
Messages: 6
Registered: October 2010
Junior Member
In my sample EntityManager.find() loads Person Entity although I set the fetch type to lazy:

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PERSON_ID")
private Person person;

Why ? My expection is that EclipseLinks reads the db row during getPerson() invocation.
Many thanks,
Martin
Re: EclipseLink 2.1.1 / Problem with @ManyToOne(fetch = FetchType.LAZY) [message #631295 is a reply to message #631242] Wed, 06 October 2010 20:37 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
Have you either specified the -javaagent option when starting Java (dynamic weaving) or postprocessed the classes (static weaving)? This puts in a decoupling layer on the variables which allows for lazy loading.

http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_ (ELUG)#How_to_Configure_Dynamic_Weaving_for_JPA_Entities_Usi ng_the_EclipseLink_Agent

Tom



On 6-10-2010 18:26, Martin Weiss wrote:
> In my sample EntityManager.find() loads Person Entity although I set the fetch type to lazy:
>
> @ManyToOne(fetch = FetchType.LAZY)
> @JoinColumn(name = "PERSON_ID")
> private Person person;
>
> Why ? My expection is that EclipseLinks reads the db row during getPerson() invocation.
> Many thanks,
> Martin
Re: EclipseLink 2.1.1 / Problem with @ManyToOne(fetch = FetchType.LAZY) [message #631356 is a reply to message #631295] Thu, 07 October 2010 08:37 Go to previous message
Martin Weiss is currently offline Martin WeissFriend
Messages: 6
Registered: October 2010
Junior Member
Hi Tom,
many thanks for your answer. Lazy loading of JPA entities works perfectly for me when deploying to the JEE application server. However, when I am testing with JUnit in Eclipse, lazy loading is not enabled. I added -javaagent:eclipselink.jar to the JUnit configuration (program arguments). Any other ideas ?
Regards,
Martin
Previous Topic:JPQL where condition problem
Next Topic:OneToOne mapping on same table
Goto Forum:
  


Current Time: Fri Apr 26 19:52:41 GMT 2024

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

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

Back to the top