The persistence.xml file is vanilla. It does not override any weaving hints. So I am assuming that we will get the maximum lazy-load possible ( this is what I see in the server logs ). In a debugger I see that a org.eclipse.persistence.indirection.IndirectMap is used to hold the "mapItems" map attribue of the class. The IndirectMap starts with a delegate of type org.eclipse.persistence.internal.indirection.UnitOfWorkQueryValueHolder. When I perform a .get(key) on "mapItems" this causes a query to load ALL of the MapItems referenced by the Singleton "mapItems".

If we have a large number of items in the map this obviously gives us a performance overhead. We know we can restructure our code so this does not happen ( i.e. model things differently ). However before we embark on this...

1) Is there any way to set up this OneToMany so that only one item ( or a reduced set ) is retrieved at a time?

2) Has anyone any advice or pattern that we can use to change the representation of this map? For example explicitly split the keys and values into different Sets that we can join/manage on our own?

Thanks]]>J F2011-07-25T12:41:06-00:00(no subject)https://www.eclipse.org/forums/index.php/mv/msg/224116/701915/#msg_701915
2 - You can define each element as a separate attribute, either by not having the Map or using VIRTUAL access. You could map each using a OneToOne mapping, possibly with a selectCriteria Expression.

Or you could remove the attributes entirely and only query for the desired objects.