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.
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.