-->
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: Query Interface with Outer Join
PostPosted: Tue May 11, 2004 8:16 am 
Newbie

Joined: Wed May 05, 2004 5:48 pm
Posts: 3
use hibernate 2.1.3:


have a mapping as follows (with some simplification):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping auto-import="false">
<class
name="PersistentAlarm" table="ALR">
<id name="id" type="long">
<generator class="sequence">
<param name="sequence">ALR_SEQ</param>
<param name="table">ALR_UIDTABLE</param>
<param name="column">ALR0000_HIVALUECOLUMN</param>
</generator>
</id>

<property name="eventtime" length="7" type="calendar">
<column name="eventtime" index="index_eventtime"/>
</property>
<property name="additionaltext" length="2047" type="string">
<column name="additionaltext" index="index_additionaltext"/>
</property>
<set name="additionalinformation" table="PROPERTY" inverse="true" cascade="none" outer-join="true">
<key column="entry_id"/>
<one-to-many class="PersistentAlarm"/>
</set>
</class>
</hibernate-mapping>


in addition i have set "hibernate.use_outer_join" to "true" globally for hibernate.


use hibernate Query interface to get items and their children.

Query q = sess.createQuery("from ALR alarm");
q.setFirstResult(20);
q.setMaxResults(10);
List alarms = q.list();


hibernate will select the master table (ALR) at first then select the slave table (PROPERTY)
by every result record in the master table. It generates many SQL commands. it doesn't use
the outer-join as i thought to fetch the stuffs in one SQL command!


can i configure hibernate to select master and slave table altogether using outer-join and
then auto split the results into correct java classes?


many thanx!

-- bs


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 11, 2004 8:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Use left join fetch in your HQL.


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.