| OneToOne lazy relationship was already fetched? [message #604491] |
Tue, 21 September 2010 15:33  |
Mauro Flores Messages: 83 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  |
James Sutherland Messages: 1834 Registered: July 2009 |
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
|
|
|
Powered by
FUDForum. Page generated in 0.04545 seconds