-->
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: Fetch many in a single select
PostPosted: Wed Feb 21, 2007 11:05 am 
Newbie

Joined: Wed Jan 17, 2007 10:32 am
Posts: 6
Good day. I am working to introduce Hibernate to an organization that is big into stored procedures and writing out all of the SQL. That said, they are looking at Hibernate very closely and picking out everything. While viewing the SQL trace our DBA has noticed that when doing a select for a one to many relationship, its doing a single select for each and every entity on the many side of the relationship. They don't like this. Performance concerns I suppose. At any rate, is there a setting to get Hibernate to make this request with one query?

My desired outcome would to have the collection lazily loaded, but when it is loaded, that it is done with one select statement. I can not trade the lazy approach for a single select due to performance concerns.

Thanks Hibernate community and developers.

~ Mike


Hibernate version:
Code:
<dependency>
  <groupId>hibernate</groupId>
  <artifactId>hibernate</artifactId>
  <version>3.2.1</version>
  <!-- http://www.hibernate.org/ -->
</dependency>


Mapping documents:

Code:
<hibernate-mapping default-access="field"
                   package="com.myco.myapp.internal.model"
                   schema="database.schema">

    <class name="GuidelineSet" table="CodesOwners" lazy="false">

        <id name="id" column="OwnerId">
            <generator class="identity"/>
        </id>

        <property name="name" column="OwnerName"/>
        <property name="pedsPrefix" column="GuidelinePrefixPeds" lazy="true"/>
        <property name="adultPrefix" column="GuidelinePrefixAdult" lazy="true"/>

        <!-- guidelines (one-to-many) -->
        <set name="guidelines"
             table="guidelines"
             access="field"
             lazy="true"
             cascade="all, delete-orphan"
             fetch="join">
            <key column="OwnerId"/>
            <one-to-many class="InternalGuideline" not-found="ignore"/>
        </set>

    </class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Using Spring ORM - HibernateTemplate.

Name and version of the database you are using:
    jTDS Type 4 JDBC Driver for MS SQL Server and Sybase
    Microsoft SQL Server


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 21, 2007 2:23 pm 
Newbie

Joined: Wed Jan 17, 2007 10:32 am
Posts: 6
I think I have solved this problem, which was not a problem. I am looking at my HQL queries now. I may have written it to do this : \


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.