-->
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: Why am I getting inner join when mapping fetch is select?
PostPosted: Fri Dec 07, 2007 12:06 pm 
Newbie

Joined: Thu Aug 10, 2006 9:43 am
Posts: 7
Location: South West UK
Hi,

I have a mapping file that seems to be generating inner joins (oracle and oracle9 dialect) and I can't figure out why and as a result I'm getting an artificially restricted result set

Can anyone point out why this is happening? - I thought the fetch="select" would override this - I've tried setting fetch mode on the criteria object to select and it has no effect?

Any help much appreciated

Richard

Hibernate version: 1.2

Mapping documents:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="BCM3.Businessentities" namespace="Northgate.LandProperty.BCM3.BusinessEntities">
<class name="BCApplication" table="BCAPPLICATION">
<cache usage="read-write"/>
<id name="UniqueId" column="REFERENCE">
<generator class="sequence">
<param name="sequence">BCAPPLICATION_SQ</param>
</generator>
</id>
<property name="ReferenceNumber" column="APPLICATION_NUMBER" type="AnsiString"/>
<property name="CreatedDate" column="CREATE_DATE"/>
<property name="CreatedBy" column="CREATE_BY" type="AnsiString"/>
<bag name="SiteVisits" lazy="false" fetch="subselect">
<key column="BCA_REFERENCE"/>
<one-to-many class="SiteVisit"/>
</bag>
<bag name="Phases" lazy="false" fetch="subselect" >
<key column="BCA_REFERENCE"/>
<one-to-many class="BCApplicationPhase"/>
</bag>
<one-to-one name="SiteDetail" class="BCApplicationSiteDetail" fetch="select" lazy="false"/>
<one-to-one name="Site" class="BCApplicationSite" property-ref="ApplicationUniqueId" fetch="select" lazy="false"/>
<one-to-one name="Owner" class="Owner" property-ref="ApplicationUniqueId" fetch="select" lazy="false"/>
<one-to-one name="Agent" class="Agent" property-ref="ApplicationUniqueId" fetch="select" lazy="false"/>
<property name="SiteAddress" column="SITE_ADDRESS" type="AnsiString"/>
<property name="Description" column="DEVELOPMENT_DESCRIPTION" type="AnsiString"/>
</class>
</hibernate-mapping>

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



Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

DEBUG NHibernate.SQL - SELECT this_.REFERENCE as REFERENCE38_1_, this_.APPLICATION_NUMBER as APPLICAT2_38_1_, this_.CREATE_DATE as CREATE3_38_1_, this_.CREATE_BY as CREATE4_38_1_, this_.SITE_ADDRESS as SITE5_38_1_, this_.DEVELOPMENT_DESCRIPTION as DEVELOPM6_38_1_, sitevisit1_.COUNTER as COUNTER39_0_, sitevisit1_.BCA_REFERENCE as BCA2_39_0_, sitevisit1_.CREATE_DATE as CREATE3_39_0_, sitevisit1_.CREATE_BY as CREATE4_39_0_, sitevisit1_.SCHEDULED_DATETIME as SCHEDULED5_39_0_, sitevisit1_.SCHEDULED_DURATION as SCHEDULED6_39_0_, sitevisit1_.ACTUAL_DATETIME as ACTUAL7_39_0_, sitevisit1_.ACTUAL_DURATION as ACTUAL8_39_0_, sitevisit1_.OFFICER_CODE as OFFICER9_39_0_, sitevisit1_.DIARY_REFERENCE as DIARY10_39_0_, sitevisit1_.TEAM_CODE as TEAM11_39_0_, sitevisit1_.EFFECT_DATE as EFFECT12_39_0_, sitevisit1_.REQUESTED_DATETIME as REQUESTED13_39_0_, sitevisit1_.NOTES as NOTES39_0_, sitevisit1_.OFFICE_TIME as OFFICE15_39_0_, sitevisit1_.TRAVEL_TIME as TRAVEL16_39_0_, sitevisit1_.MILEAGE as MILEAGE39_0_, sitevisit1_.TOTAL_COST as TOTAL18_39_0_ FROM BCAPPLICATION this_ inner join BCSITE_VISIT sitevisit1_ on this_.REFERENCE=sitevisit1_.BCA_REFERENCE WHERE this_.REFERENCE in (:p0, :p1); :p0 = '756', :p1 = '757'


Top
 Profile  
 
 Post subject: Re: Why am I getting inner join when mapping fetch is select
PostPosted: Fri Dec 07, 2007 12:54 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
gaspode44 wrote:
Hi,

I have a mapping file that seems to be generating inner joins (oracle and oracle9 dialect) and I can't figure out why and as a result I'm getting an artificially restricted result set

Can anyone point out why this is happening? - I thought the fetch="select" would override this - I've tried setting fetch mode on the criteria object to select and it has no effect?

Any help much appreciated

Richard


Richard,

It must have something to do with your HQL. Fetch settings might be ignored if associations are used in HQL. Can you post your HQL that results in that SQL output?


Farzad-


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.