-->
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: Set, Fetch -Performance Tuning
PostPosted: Wed Sep 19, 2007 6:39 am 
Newbie

Joined: Wed Sep 19, 2007 6:19 am
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0

I have category objects inside content object with ONE TO MANY relationships.

My Mapping for SET tag is working but it is taking much time to load the data in JSP page.

Could you please suggest us in performance tunning the SET TAG.

1. Is it advisiable to use lazy="true" in set tag
2. What makes the difference in using [b]batch-size in set tag and content class.

Also could you suggest us what would be the reasons for low performance(loading of database records) using the collections like <SET



In below example:

persistence.ContentCategory is the collection of objects to be loaded along with "persistence.Content" objects.The relations ship is simple and it is working.But there is performance hit if the number of content objects are more then 10 records.

-----------------------------------------------------

Content mapping file.
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="persistence.Content" table="content">

<id name="contentId" column="content_id" type="long">
<generator class="sequence"/>
</id>
<set name="contentsAndCategories" table="content_category" cascade="all" lazy="false">
<key column="content_id"/>
<[b]one-to-man
y class="persistence.ContentCategory"/>
</set> [/b]
</class>
</hibernate-mapping>
---------------------------------

Mapping file related to the collection for a set tag in the content mapping object.


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="persistence.ContentCategory" table="content_category">
<id name="contentCategoryId" column="content_category_id" type="long">
<generator class="sequence"/>

</id>
<many-to-one name="content" column="content_id" class="persistence.Content" lazy="false" />
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 19, 2007 8:55 am 
Beginner
Beginner

Joined: Fri May 18, 2007 10:28 am
Posts: 48
Location: Madison, WI
Hibernate is slow when it is loading, but once it is done loading it blazes in performance. Setting lazy init true is sure better thing, if you don't want to load all the set objects until requested for.
How you can test it, add the lazy tag and goto variable view in your IDE to see how Hibernate loads and unloads data.

_________________
Please rate if it helped


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.