Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » User defined (custom) collections
icon5.gif  User defined (custom) collections [message #508040] Fri, 15 January 2010 11:15 Go to next message
Craig M is currently offline Craig M
Messages: 19
Registered: July 2009
Junior Member
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?

Thanks.
Re: User defined (custom) collections [message #508359 is a reply to message #508040] Mon, 18 January 2010 09:44 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

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.

See also,
http://en.wikibooks.org/wiki/Java_Persistence/Relationships# Collection_Implementations


James : Wiki : Book : Blog : Twitter
Re: User defined (custom) collections [message #509942 is a reply to message #508359] Mon, 25 January 2010 15:25 Go to previous messageGo to next message
Craig M is currently offline Craig M
Messages: 19
Registered: July 2009
Junior Member
OK, so can we implement our own LAZY collection implementation for EclipseLink and configure it to use that for certain relationships? Or is this the latest feature request? Laughing
Re: User defined (custom) collections [message #510746 is a reply to message #508040] Thu, 28 January 2010 09:32 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

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.


James : Wiki : Book : Blog : Twitter
Previous Topic:Problem with indirect (lazy) mappings
Next Topic:2.0.0: where did the commit go?
Goto Forum:
  


Current Time: Sat Aug 23 05:42:33 EDT 2014

Powered by FUDForum. Page generated in 0.01833 seconds