-->
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: single fetch with many-to-one
PostPosted: Mon Apr 24, 2006 4:49 am 
Newbie

Joined: Wed Mar 29, 2006 2:24 am
Posts: 14
i couldn't seem to make a many-to-one relationship use a single fetch with a join statement. anything i am missing here?


Hibernate version: NHibernate 1.0.2.0

Mapping documents:
<class name="CDB.Core.Region, CDB.Core" table="Region">
<id name="_id" column="ID">
<generator class="native"/>
</id>
<property name="_code" column="RegionCode" unique="true"/>
<property name="_name" column="Name"/>
</class>


<class name="CDB.Core.Country, CDB.Core" table="Country">
<id name="_id" column="ID">
<generator class="native"/>
</id>
<property name="_code" column="CountryCode" unique="true"/>
<property name="_name" column="Name"/>
<many-to-one name="_region" class="Region" column="RegionCode" fetch="join" property-ref="_code"/>
</class>

The generated SQL (show_sql=true):

NHibernate: select country0_.ID as ID, country0_.CountryCode as CountryC2_, country0_.Name as Name, country0_.RegionCode as RegionCode from Country country0_ order by country0_.ID
NHibernate: SELECT region0_.ID as ID0_, region0_.RegionCode as RegionCode0_, region0_.Name as Name0_ FROM Region region0_ WHERE region0_.RegionCode=@p0
@p0 = 'AP'
NHibernate: SELECT region0_.ID as ID0_, region0_.RegionCode as RegionCode0_, region0_.Name as Name0_ FROM Region region0_ WHERE region0_.RegionCode=@p0
@p0 = 'AP'
NHibernate: SELECT region0_.ID as ID0_, region0_.RegionCode as RegionCode0_, region0_.Name as Name0_ FROM Region region0_ WHERE region0_.RegionCode=@p0
@p0 = 'AP'
NHibernate: SELECT region0_.ID as ID0_, region0_.RegionCode as RegionCode0_, region0_.Name as Name0_ FROM Region region0_ WHERE region0_.RegionCode=@p0
@p0 = 'AP'
NHibernate: SELECT region0_.ID as ID0_, region0_.RegionCode as RegionCode0_, region0_.Name as Name0_ FROM Region region0_ WHERE region0_.RegionCode=@p0
@p0 = 'NA'
NHibernate: SELECT region0_.ID as ID0_, region0_.RegionCode as RegionCode0_, region0_.Name as Name0_ FROM Region region0_ WHERE region0_.RegionCode=@p0
@p0 = 'SA'
NHibernate: SELECT region0_.ID as ID0_, region0_.RegionCode as RegionCode0_, region0_.Name as Name0_ FROM Region region0_ WHERE region0_.RegionCode=@p0
@p0 = 'EU'
NHibernate: SELECT region0_.ID as ID0_, region0_.RegionCode as RegionCode0_, region0_.Name as Name0_ FROM Region region0_ WHERE region0_.RegionCode=@p0
@p0 = 'AP'

_________________
http://devpinoy.org/blogs/joeycalisay


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.