First post so bare with me, and I've search for quite a while and not found any answers.
I'm working on a school project where we are testing performance with different ORM's compared to JDBC and I'm having a big issue with OpenJPA when using a ManyToMany relation. We're trying to do a simple select case where we run a for loop with 500 iterations while calling a findById method that returns the instance. Wearhouse instance = getOJPAEntityManager().find(Wearhouse.class, id); This takes roughly 1~ sec on JDBC and 1.2~ EclipseLink while it takes 10+ sec on OpenJPA. This only happens with ManyToMany! We have plenty of insert tests, select tests etc and all of them are much more similar, with openjpa winning and losing a few. Now, I'll gladly admit we dont have to much experience with this, but this strikes me as very odd. So, if anyone has any tips, comments or info I'll be glad to try it out. Thanks in advance! Marius Here are the two entities in question: package project.common.model; import java.util.*; import javax.persistence.*; @Entity public class Wearhouse { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer wearhouseNr; private String wearhouseName; @ManyToMany(cascade={CascadeType.PERSIST}, fetch = FetchType.EAGER) @JoinTable( name="wearhouse_storagecategory", joincolum...@joincolumn(name="wearhouseNr"), inversejoincolum...@joincolumn(name="storagecategoryNr") ) private List<Storagecategory> storageCategories; public Wearhouse() { } public Wearhouse(String wearhouseName) { this.wearhouseName = wearhouseName; storageCategories = new ArrayList<Storagecategory>(); } public Integer getWearhouseNr() { return this.wearhouseNr; } public void setWearhouseNr(Integer wearhouseNr) { this.wearhouseNr = wearhouseNr; } public String getWearhouseName() { return this.wearhouseName; } public void setWearhouseName(String wearhouseName) { this.wearhouseName = wearhouseName; } public void setStorageCategories(List<Storagecategory> storageCategory){ this.storageCategories = storageCategory; } public List<Storagecategory> getStorageCategories(){ return storageCategories; } public void addStorageCategories(Storagecategory storagecategory) { if(storageCategories == null) storageCategories = new ArrayList<Storagecategory>(); storageCategories.add(storagecategory); } } package project.common.model; import java.util.*; import javax.persistence.*; @Entity public class Storagecategory { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer storagecategoryNr; private String storageCategoryName; @ManyToMany(mappedBy="storageCategories", cascade={CascadeType.PERSIST}) private List<Wearhouse> wearhouses; public Storagecategory() { } public Storagecategory(String storageCategoryName) { this.storageCategoryName = storageCategoryName; } public Integer getStoragecategoryNr() { return this.storagecategoryNr; } public void setStoragecategoryNr(Integer storagecategoryNr) { this.storagecategoryNr = storagecategoryNr; } public String getStorageCategoryName() { return this.storageCategoryName; } public void setStorageCategoryName(String storageCategoryName) { this.storageCategoryName = storageCategoryName; } public List<Wearhouse> getWearhouses() { return wearhouses; } public void setWearhouses(List<Wearhouse> wearhouses) { this.wearhouses = wearhouses; //Wearhouse owns the relation, therefor we have to tell these //wearhouses this storargecategories is on of the wearhouse's storagecategories. for (Wearhouse wearhouse : wearhouses) wearhouse.addStorageCategories(this); } } -- View this message in context: http://n2.nabble.com/Slow-performance-with-OpenJPA-when-selecting-from-a-ManyToMany-relation.-tp2466994p2466994.html Sent from the OpenJPA Users mailing list archive at Nabble.com.