(no subject) [message #701701] |
Mon, 25 July 2011 08:41  |
Eclipse User |
|
|
|
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
e.g.
@Entity
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>();
}
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn
public class MapItem implements IMapItem {
@SuppressWarnings("unused") //used by JPA
@ManyToOne
private Singleton singleton;
@Basic
private String cachedKey;
@Id
private String id;
@Version
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?
Thanks
|
|
|
|
Powered by
FUDForum. Page generated in 0.07433 seconds