Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » OneToOne lazy relationship was already fetched?
OneToOne lazy relationship was already fetched? [message #604491] Tue, 21 September 2010 19:33 Go to next message
Mauro Flores is currently offline Mauro FloresFriend
Messages: 84
Registered: September 2009
Location: Brasil
How can I know if an lazy OneToOne (Or a ManyToOne) relationship was already loaded ?
I'm working with eclipselink 1.2.1.

For an OneToMany or ManyToMany relationship, I get the Collection (or Map) content and see if it is an IndirectCollection. But with a XxxToOne, if I get the content the fetch is executed.

Thanks. Mauro.
Re: OneToOne lazy relationship was already fetched? [message #628641 is a reply to message #604491] Thu, 23 September 2010 13:58 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

The best way is probably to get the ClassDescriptor for the class from the EclipseLink Session (from the JpaEntityManager), then get the OneToOneMapping from the descriptor and ask it if the attribute is instantiated, (mapping.isAttributeValueInstantiated(entity)).

This will work for OneToMany as well, (note just because it is an IndirectCollection, does not mean that it may not be instantiated already).

James : Wiki : Book : Blog : Twitter
Previous Topic:Chain of eager relationships
Next Topic:Trouble upgrading from EclipseLink 1.1.2 to 2.1.1 in Spring 2.5
Goto Forum:

Current Time: Sat May 26 19:57:49 GMT 2018

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

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

Back to the top