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 15:33 Go to next message
Mauro Flores is currently offline Mauro Flores
Messages: 84
Registered: September 2009
Location: Brasil
Member
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 09:58 Go to previous message
James Sutherland is currently offline James Sutherland
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: Fri Aug 22 23:50:57 EDT 2014

Powered by FUDForum. Page generated in 0.02396 seconds