Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » (no subject)
(no subject) [message #689994] Tue, 28 June 2011 13:31 Go to next message
James is currently offline James
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] Tue, 28 June 2011 21:21 Go to previous messageGo to next message
Boyd Pang is currently offline Boyd Pang
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 03:17 Go to previous messageGo to next message
Boyd Pang is currently offline Boyd Pang
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 03:17]

Report message to a moderator

(no subject) [message #690999 is a reply to message #690755] Thu, 30 June 2011 10:12 Go to previous messageGo to next message
James is currently offline James
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] Thu, 30 June 2011 21:11 Go to previous message
Boyd Pang is currently offline Boyd Pang
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 Aug 22 19:45:00 EDT 2014

Powered by FUDForum. Page generated in 0.01750 seconds