-->
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 Join Error
PostPosted: Fri Feb 12, 2010 1:43 pm 
Newbie

Joined: Fri Feb 12, 2010 12:53 pm
Posts: 1
I want my loads to perform joins instead of selects. I have read the documentation and have tried to configure my classes to load using joins, but the logs show they are using selects.

VesselStack has an ISet of VesselSpot
VesselSpot has an ISet of VesselTelemetry

When performing a load of VesselStack I see multiple selects in the logs instead of one select with outer joins.

Any suggestions on why this is not working?

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
    <property name="connection.connection_string">User ID=Foo;Password=Bar;Data Source=fooBar</property>
    <property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
    <property name="connection.isolation">ReadCommitted</property>
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
    <property name="max_fetch_depth">4</property>
    <property name="show_sql">true</property>
  </session-factory>
</hibernate-configuration>


Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                   assembly="Server"
                   namespace="Model"
                   default-cascade="save-update">

  <class name="VesselStack" table="VESSEL_STACK" dynamic-update="true">
    <id name="VesselStackId" column="VESSEL_STACK_ID">
      <generator class="uuid.hex" />
    </id>
    <property name="BayIso" column="BAY_ISO"/>
    <property name="StackIso" column="STACK_ISO"/>
    <set name="VesselSpots" table="VESSEL_SPOT" inverse="true" cascade="all" fetch="join" lazy="false" sort="VesselSpotComparer">
      <key column="VESSEL_STACK_ID" />
      <one-to-many class="VesselSpot" />
    </set>
  </class>

  <class name="VesselSpot" table="VESSEL_SPOT" dynamic-update="true">
    <id name="VesselSpotId" column="VESSEL_SPOT_ID">
      <generator class="uuid.hex" />
    </id>
    <property name="SpotIso" column="SPOT_ISO"/>
    <set name="VesselTelemetries" table="VESSEL_TELEMETRY" inverse="true" cascade="all" fetch="join" lazy="false" sort="VesselTelemetryComparer">
      <key column="VESSEL_SPOT_ID" />
      <one-to-many class="VesselTelemetry"/>
    </set>
    <many-to-one name="VesselStack" class="VesselStack" column="VESSEL_STACK_ID" cascade="save-update" fetch="join" lazy="false" not-null="true"/>
  </class>

  <class name="VesselTelemetry" table="VESSEL_TELEMETRY" dynamic-update="true">
    <id name="VesselTelemetryId" column="VESSEL_TELEMETRY_ID">
       <generator class="uuid.hex" />
    </id>
    <property name="ResultBayIso" column="RESULT_BAY_ISO"/>
    <property name="ResultStackIso" column="RESULT_STACK_ISO"/>
    <property name="ResultTierIso" column="RESULT_TIER_ISO"/>
    <many-to-one name="VesselSpot" class="VesselSpot" column="VESSEL_SPOT_ID" cascade="save-update" fetch="join" lazy="false" not-null="true"/>
  </class>
 
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: Fetch Join Error
PostPosted: Sat Feb 13, 2010 6:15 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
How do you load ? If you use a HQL query the fetch mode in the mappaing is ignored. YOu have to spefify it directly in the query.

from VesselStack st left join fetch st.VesselSpot sp left join fetch sp.VesselTelemetry

_________________
--Wolfgang


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.