-->
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.  [ 1 post ] 
Author Message
 Post subject: outer-join not working on many-to-one
PostPosted: Mon Apr 04, 2005 11:26 pm 
Newbie

Joined: Thu Jan 06, 2005 4:41 pm
Posts: 8
Now that i have read the FAQs, the forums and the documentation, i'm out of ideas on this one. I know I must be doing something wrong, but I just don't see it. This mapping setup used to work with hibernate 2.1. Modifying them for hibernate 3 seems to have changed the bahavior and I do not know why.

I have 2 object Profile and ContactInfo. Profile references ContacInfo with a nullable foreign key. What I want is that both objects be loaded in the same query with an outer-join. Here is my setup:

Hibernate version: 3.0.final

Mapping documents:

Code:
<hibernate-mapping package="com.server.data.profile">

   <class name="Profile" table="profile" lazy="false">

      <id name="uid" column="id">
         <generator class="native"/>
      </id>

      <property name="firstName" column="firstname" not-null="true" length="50" lazy="false"/>
      <property name="lastName" column="lastname" not-null="true" length="50" lazy="false"/>
      <property name="gender" column="gender" not-null="true" lazy="false"/>
      <property name="dateOfBirth" type="date" column="birthdate" not-null="true" lazy="false"/>
      <property name="passport" column="passport" not-null="false" length="10" lazy="false"/>
      <property name="creationDate" column="creationdate" type="date" not-null="true" lazy="false"/>
      <property name="description" column="notes" type="text" not-null="true" lazy="false"/>
      <property name="deleted" column="isdeleted" not-null="true" lazy="false"/>

      <many-to-one name="contactInfo" column="contactinfoid" not-null="false" unique="true" cascade="all" outer-join="true" fetch="join" lazy="false"/>

   </class>

   <class name="ContactInfo" table="contactinfo" lazy="false">

      <id name="uid" column="id">
         <generator class="native"/>
      </id>

      <property name="primaryPhone" column="phone1" not-null="true" lazy="false" length="20"/>
      <property name="secondaryPhone" column="phone2" not-null="false" lazy="false" length="15"/>
      <property name="email" column="email" not-null="false" lazy="false" length="100"/>
      <property name="address" column="address" not-null="true" lazy="false" length="255"/>
      <property name="postalCode" column="postalcode" not-null="false" lazy="false" length="8"/>
      <property name="city" column="city" not-null="true" lazy="false" length="50"/>

   </class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Code:
String query = "SELECT profile FROM Profile profile";
List dtos = session.createQuery(query).list();


Name and version of the database you are using:
MySQL 4.1.10-nt

The generated SQL (show_sql=true):

23:20:06,343 INFO [STDOUT] Hibernate: select profile0_.id as id, profile0_.firstname as firstname1_, profile0_.lastname as lastname1_, profile0_.gender as gender1_, profile0_.birthdate as birthdate1_
, profile0_.passport as passport1_, profile0_.creationdate as creation7_1_, profile0_.notes as notes1_, profile0_.isdeleted as isdeleted1_, profile0_.contactinfoid as contact10_1_ from profile profile
0_
23:20:06,859 INFO [STDOUT] Hibernate: select contactinf0_.id as id0_, contactinf0_.phone1 as phone2_2_0_, contactinf0_.phone2 as phone3_2_0_, contactinf0_.email as email2_0_, contactinf0_.address as
address2_0_, contactinf0_.postalcode as postalcode2_0_, contactinf0_.city as city2_0_ from contactinfo contactinf0_ where contactinf0_.id in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

Debug level Hibernate log excerpt:

I've enabled DEBUG but there does not seem any message related to why ContactInfo is not loaded together with Profile. I have tried to play with the parameters of many-to-one like removing fetch or outer-join but it is always the same result.

Note that max_fetch_depth is set to 2 and default_batch_fetch_size to 16.

Can someone shed some light on this?

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.