Monika Dullo

Greenhorn
+ Follow
since Mar 14, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Monika Dullo

Thanks for the reply Mark.

I was more concerned about the consistency. In the above case we have different cache regions for children namely as org.demo.parent.children and org.demo.children then if one of them is updated the other one would not reflect that change. So will this not affect the consistency or shall the changes be propagated everywhere?? Kindly clarify this.

Doesn't the above configuration kind of mean that we shall have 2 cache regions for the same table/class??
Also my understanding of the above scenario is like this

org.demo.parent cache region will be something like this in dehydrated form:
id - name - {children ids} ::: These {children ids would point towards the org.demo.parent.children cache region and NOT to org.demo.children }

org.demo.parent.children will be smthng like this
id - name - parent_id

there would also be org.demo.children cache region which would be like org.demo.parent.children cache region but will be entirely different from it:
id - name - parent_id

Doesn't this kind of lead to redundancy and thereby inconsistency if one the regions is updated? Should then the associations then be mapped to the same table (example: to org.demo.children in the above case) to which they belong when caching them?

Kindly provide your inputs and comments on this.
Hi all,

I am a newcomer to hibernate. It would be great if someone could comment over the following query that i have:

Say i have a parent class and each parent has multiple children. So the mapping file of parent class would be something like:

parent.hbm.xml

<hibernate-mapping >
<class name="org.demo.parent" table="parent" lazy="true">
<cache usage="read-write" region="org.demo.parent"/>
<id name="id" column="id" type="integer" length="10">
<generator class="native">
</generator>
</id>
<property name="name" column="name" type="string" length="50"/>

<set name="children" lazy="true">
<cache usage="read-write" region="org.demo.parent.children" />
<key column="parent_id"/>
<one-to-many class="org.demo.children"/>
</set>

</class>
</hibernate-mapping>


*************
children.hbm.xml

<hibernate-mapping >
<class name="org.demo.children" table="children" lazy="true">
<cache usage="read-write" region="org.demo.children"/>
<id name="id" column="id" type="integer" length="10">
<generator class="native">
</generator>
</id>

<property name="name" column="name" type="string" length="50"/>

<many-to-one name="parent_id" column="parent_id" type="integer" length="10" not-null="true"/>

</class>
</hibernate-mapping>


So for the set children, should we specify the region org.demo.parent.children where it should cache the association or should we use the cache region of org.demo.children where the children would be getting cached.

I am using EHCache as the 2nd level cache provider. I tried to search for the answer to this question but couldnt find any answer in this direction. It makes more sense to use org.demo.children but I dont know in which scenarios one should use a separate cache region for associations/sets/collections as in the above case. Kindly provide your inputs also let me know if I am not clear in my question.

Thanks all.