-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Session.isDirty() performs bad when using <many-to-many&g
PostPosted: Wed May 25, 2005 6:01 am 
Newbie

Joined: Wed May 18, 2005 5:16 am
Posts: 3
Hi!

I have two Objects, namely ProductClass and Resource. A ProductClass can have zero or more Resources and a Resource can belong to multiple ProductClasses (a many-to-many relation). The (simplified) Java code of the ProductClass is as follows:

Code:
class ProductClass {
    private Set resources;

    public Set getResources() {
        return resources;
    }

    public void setResources(Set resources) {
        this.resources = resources;
    }
}


And the mapping is as follows:

Code:
<class name="nl.xiam.ps.ProductClass" table="productclasses">
      <id name="id" column="classId" unsaved-value="0">
         <generator class="increment"/>
      </id>
      
      <property name="classCode"/>
      <property name="classTitle"/>
      
      <property name="classSynonyms" type="nl.xiam.ps.StringSetType"/>
      
      <set name="resources" table="classresources" cascade="all">
         <key column="classId"/>
         <many-to-many column="resourceId" class="nl.xiam.ps.Resource"/>
      </set>
       
      <many-to-one name="schemaLevel" class="nl.xiam.ps.SchemaLevel" column="schemaLevelId"/>
   </class>
   
   <class name="nl.xiam.ps.Resource" table="resources">
      <id name="id" column="resourceId" unsaved-value="0">
         <generator class="increment"/>
      </id>
      
      <property name="code" column="resourceCode"/>
      <property name="title" column="resourceTitle"/>
      <property name="content"/>
      <property name="mimeType"/>
      <property name="url" type="nl.xiam.ps.UrlType"/>
   </class>


In my application the user is able to edit ProductClasses and Resources. After he is finished editing, he can save the changes with a Save button. This button is only enabled if an Object has changed, using Session.isDirty().

But for some reason unknown to me, Session.isDirty() takes up a lot of time, e.g. a few seconds, even with a few ProductClasses and Resources. If I remove the many-to-many relation between ProductClass and Resource from the mapping, Session.isDirty() is as fast as I expect to be.

Is it normal for Session.isDirty() to take up that much time when using a many-to-many relation? Am I missing here something?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 6:29 am 
Newbie

Joined: Wed May 18, 2005 5:16 am
Posts: 3
Never mind :S

I already solved the problem. I 've implemented my own URL type, i.e. UrlType.
UrlType.equals(Object value, Object other) invokes java.net.URL.equals(Object other). From the Javadoc from URL.equals():

Quote:
Two hosts are considered equivalent if both host names can be resolved into the same IP addresses; else if either host name can't be resolved, the host names must be equal without regard to case; or both host names equal to null.


Resolving the hosts probably takes up that much time...

Thanks anyway!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.