-->
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: hibernate query regarding performance
PostPosted: Fri Jul 14, 2006 5:49 am 
Beginner
Beginner

Joined: Mon Mar 14, 2005 9:07 am
Posts: 27
Hi everone,

I have a samll query. I have a prent and a child class the mapping of which is mentioned below. I add a child to a parent in the following manner by using addChild function in the Parent class

Code:
    public void addChild(Child child) {
        this.getChildren().add(child);
    }



I need to ask that if a parent class has 10,000 children then in order to add 10001 child will hibernate load all the 10,000 children first. If yes is there any other way of preventing this overhead?

Also does using set/list make any difference to the overhead or performance.

Hibernate version:3.0

[b]Mapping documents:
Code:
<?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 package="org.hibernate.parentChild">
    <class name="Parent">
        <id name="id" column="PARENT_ID">
            <generator class="increment"/>
        </id>

      <version name="version" type="long" />

        <property name="type"/>

        <set name="children" lazy="true" cascade="all" >
            <key column="parent_id" not-null="true"/>
            <one-to-many class="Child"/>
        </set>
    </class>

    <class name="Child">
        <id name="id" column="CHILD_ID">
            <generator class="increment"/>
        </id>

        <many-to-one name="user" column="USER_ID" class="Usr" cascade="all" />
    </class>
   
   <class name="Usr" table="USR">
        <id name="id" column="USER_ID">
            <generator class="increment"/>
        </id>
   
      <property name="firstName" type="string" column="firstName" not-null="true"/>
   
      <property name="lastName" type="string" column="lastName" not-null="false"/>
   </class>
      
</hibernate-mapping>





Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 14, 2006 6:06 am 
Regular
Regular

Joined: Tue May 16, 2006 3:32 am
Posts: 117
Hibernate reference doc 19.5.2 & 19.5.3 has answers to your questions.

http://www.hibernate.org/hib_docs/v3/re ... ientupdate


http://www.hibernate.org/hib_docs/v3/re ... entinverse


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.