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?