Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How to prevent eclipse-link from loading lazy fetched attributes ?
How to prevent eclipse-link from loading lazy fetched attributes ? [message #1067563] Tue, 09 July 2013 11:03 Go to next message
Nicolas Baumgardt is currently offline Nicolas BaumgardtFriend
Messages: 5
Registered: July 2013
Junior Member
Hi

My project features a 3-tiered architecture (Glassfish 3.1.2.2, Eclipse-Link 2.3.3, Swing stand-alone client). I use JNDI and remote interfaces to access my EJB facades to communicate with the MySQL database.

For the purpose of lazy-fetching/-loading attributes of my @Entity-classes I use static weaving.

In order to reduce network traffic, I want to map the partially loaded entities to corresponding data-transfer-object (DTO). This is done on the facades.

My problem is, that the mapper does invoke all getter/setters of the entities and thus loads the un-fetched attributes. But I don't want them to be loaded during the mapping process in order to keep the transfered objects as small as possible.

Is there a way to prevent eclipse-link from fetching indirection lists ?

Many thanks for your help in advance!
Re: How to prevent eclipse-link from loading lazy fetched attributes ? [message #1067586 is a reply to message #1067563] Tue, 09 July 2013 13:06 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Not sure I understand. Your facade is building your DTOs and doing the instantiation, so if it doesn't want to instantiate the objects, then it should not call the get methods.
You need to know what you want to send in your DTO and only access that data.


James : Wiki : Book : Blog : Twitter
Re: How to prevent eclipse-link from loading lazy fetched attributes ? [message #1067602 is a reply to message #1067586] Tue, 09 July 2013 14:31 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
The context will be lost if the factory is closed or the entity is serialized, but those might be overkill for what you seem to be after - I assume you just want to send across fetched attributes but do not know which were fetched. If that is the case, EclipseLink's PersistenceProvider has a isLoadedWithReference(entity, attribute) method that you can use to test each attribute in the entity to see if it was loaded. You can use this within the Mapper, or as James suggested here http://stackoverflow.com/questions/17530290/how-to-prevent-eclipse-link-from-fetching-lazy-loaded-attributes-during-dto-mapp use a CopyGroup to create an entity instance that only contains the fetched data for your mapper to use to create the DTO. Course, you can use the CopyGroup to create the entity instance with only the relevant data and us that instance to reduce network traffic without converting to a DTO.

Best Regards,
Chris

[Updated on: Tue, 09 July 2013 14:31]

Report message to a moderator

Re: How to prevent eclipse-link from loading lazy fetched attributes ? [message #1067892 is a reply to message #1067602] Thu, 11 July 2013 07:26 Go to previous message
Nicolas Baumgardt is currently offline Nicolas BaumgardtFriend
Messages: 5
Registered: July 2013
Junior Member
james and chris, many thanks. meanwhile I tried out your suggestions and they work fine Smile. the eclipse-link's copy function ignores the unfetched attributes without throwing an exception - that's great! and moreover it's really fast.

I resigned to use these conventional reflexion based mappers since they are too slow for my requirements. therefore I decided to implement my own copy/mapping functions to map the domain objects to the data-transfer-objects using the decorator design pattern. but the copy-group feature helps me to selectively get the needed object graphs without fetching unfetched attributes.

thanks for your help!

[Updated on: Thu, 11 July 2013 07:27]

Report message to a moderator

Previous Topic:Cache coordination per entity type
Next Topic:Schema creation slow with informix
Goto Forum:
  


Current Time: Thu Apr 25 08:53:39 GMT 2024

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

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

Back to the top