Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » (no subject)
(no subject) [message #689994] Tue, 28 June 2011 17:31 Go to next message
James is currently offline JamesFriend
Messages: 272
Registered: July 2009
Senior Member
JPA requires that you use the collection interfaces Collection, List, Set or Map to allow the JPA provider to provide optimizations just as LAZY loading. It should not matter what type of Set it is, just use the Set interface. If you really want a HashSet for some specific purpose, you can define a getFooAsHashSet method that returns new HashSet(this.foo).

If you use EAGER, then by default EclipseLink will allow you to use an implementation class, but this is not possible with LAZY. EclipseLink will use an instance of IndirectSet (which contains a HashSet) for any LAZY field, this does not mean the set has not been read, just that it has the potential to be LAZY.

In general in Java it is best to use the collection interfaces in your code.

Why do you want a HashSet?
--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
(no subject) [message #690097 is a reply to message #689994] Wed, 29 June 2011 01:21 Go to previous messageGo to next message
Boyd Pang is currently offline Boyd PangFriend
Messages: 12
Registered: June 2011
Junior Member
Thank you very much James.

I am a new one to Eclipselink,and I didn't understand lazy loading very well before.I thought that if the data fetched sucessfully,the eager loading and lazy loading will have a same data structure(that is a HashSet) ,that's why I said I need a HashSet.

Now I understand the lazy loading´╝îif I set the hint "eclipselink.join-fetch",the data were fetched successfully indeed,although contained in a IndirectSet.

Once again, thank you very much.
Re: (no subject) [message #690755 is a reply to message #690097] Thu, 30 June 2011 07:17 Go to previous messageGo to next message
Boyd Pang is currently offline Boyd PangFriend
Messages: 12
Registered: June 2011
Junior Member
James,

Is there any way to know that the IndirectSet is instantiated yet ? That is data have been fetched from db.

[Updated on: Thu, 30 June 2011 07:17]

Report message to a moderator

(no subject) [message #690999 is a reply to message #690755] Thu, 30 June 2011 14:12 Go to previous messageGo to next message
James is currently offline JamesFriend
Messages: 272
Registered: July 2009
Senior Member
You can call the isInstantiated() method.
--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
Re: (no subject) [message #691221 is a reply to message #690999] Fri, 01 July 2011 01:11 Go to previous message
Boyd Pang is currently offline Boyd PangFriend
Messages: 12
Registered: June 2011
Junior Member
Thanks,I have got it.
Previous Topic:TopLink Essentials Caching Options
Next Topic:(dupliacte, ignore)
Goto Forum:
  


Current Time: Fri Dec 19 08:13:43 GMT 2014

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

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