Does EcilpseLink (or more generally, JPA) support custom collection types? I'm not talking about what is IN the collection, but the actual collection implementation itself. Can I create a specialized java.util.Set or java.util.Map in my object model and have the EntityManager use my own collection implementation for the relationships?
The JPA spec requires usage of List, Set, Collection or Map. EclipseLink requires usage of the interface is using LAZY, but allows an implementation that implements one of these interfaces if using EAGER.
If the variable type is an interface, you can assign any impl to it you want, but when EclipseLink builds an object from the database, it will put a special LAZY collection as the value.
If you wish to implement your own lazy collection you could do so.
Refer to the classes IndirectSet and IndirectMap to get an idea of how to do this. You will also need to set the ContainerPolicy on your mapping to your new collection type using a DescriptorCustomizer.
If you think you new indirect collection would be useful to other users, please feel free to contribute it back to the EclipseLink community.