Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » (no subject)
(no subject) [message #701701] Mon, 25 July 2011 12:41 Go to next message
J F is currently offline J FFriend
Messages: 256
Registered: July 2009
Senior Member
We are using;
Glassfish 3.1
Eclipselink 2.2.0.v20110202-r8913
JDK jdk1.6.0_24
Windows Server 2008 SP2

We have a number of OneToMany mappings that use java.util.Maps

public class Singleton {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "singleton")
@MapKey(name = "cachedKey")
private java.util.Map<java.lang.String, MapItem> mapItems = new java.util.HashMap<java.lang.String, MapItem>();

@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class MapItem implements IMapItem {

@SuppressWarnings("unused") //used by JPA
private Singleton singleton;

private String cachedKey;

private String id;

private int version;

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?

(no subject) [message #701915 is a reply to message #701701] Mon, 25 July 2011 17:51 Go to previous message
James is currently offline JamesFriend
Messages: 272
Registered: July 2009
Senior Member
1 - No, all elements will always be loaded.

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.

James : : :
Previous Topic:[JPA]
Next Topic:Installation of EclipseLink with Tomcat 7
Goto Forum:

Current Time: Thu May 13 05:16:20 GMT 2021

Powered by FUDForum. Page generated in 0.02472 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top