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
|