Hi Kevin,

Thanks for the reply!

We are enhancing the files. I have an Ant script enhancing the files before
every run of OpenJPA, so that is not the problem. 
Although it did give me strange results the first time I tried openjpa and
did not enhance ;)

-Shubbis


Kevin Sutter wrote:
> 
> Hi Shubbis,
> Thanks for asking before posting any results...  :-)  Much appreciated.
> 
> The first thing that comes to mind is whether you are "enhancing" your
> Entities that are used with OpenJPA.  For optimal performance, OpenJPA
> uses
> a byte-code weaving technique to enhance the Entity objects.  This
> enhancement allows for more efficient interaction between the Entity
> objects
> and the OpenJPA runtime.
> 
> This blog entry explains the various enhancement mechanisms available for
> an
> OpenJPA environment (build vs runtime):
> http://webspherepersistence.blogspot.com/2009/02/openjpa-enhancement.html
> 
> FYI, if you do not perform the byte-code enhancement either statically at
> build time or dynamically at runtime, then OpenJPA falls back to a simpler
> subclassing approach.  This subclassing approach is meant for simple
> out-of-the-box examples, and not for production or performance
> comparisons.
> This performance concern becomes especially noticeable with Eager type
> relationship fetching like it looks your example is doing.
> 
> Let's start with this enhancement processing.  If you are doing
> enhancement
> and you are still hitting this performance concern, then we need to dig
> further because we definitely do not see this type of performance concern
> when we do our comparisons...  :-)
> 
> Thanks,
> Kevin
> 
> On Thu, Mar 12, 2009 at 7:22 AM, Shubbis <marius.jo...@broadpark.no>
> wrote:
> 
>>
>> 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.
>>
>>
> 
> 

-- 
View this message in context: 
http://n2.nabble.com/Slow-performance-with-OpenJPA-when-selecting-from-a-ManyToMany-relation.-tp2466994p2467417.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to