-->
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: HQL/SQL-Discriminator Issue
PostPosted: Tue Sep 20, 2005 5:02 am 
Newbie

Joined: Sun Jul 03, 2005 3:54 am
Posts: 9
I have two tables (MeasureUnits and TranslationItems) with the following mapping,
which I mapped them like that:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="X.Data.General.Entity.MeasureUnitEntity, X.Data"
table="MeasureUnits">
<id name="Id" column="IdMeasureUnit" type="Int32" unsaved-value="0">
<generator class="native" />
</id>
<property name="Code" column="Code" type="string" not-null="true"/>
<set name="MeasureUnitNameTranslationItemSet"
cascade="none"
inverse="false"
lazy="true">
<key column="IdDbRecord"/>
<one-to-many class="X.Data.Translations.Entity.MeasureUnitNameTranslationItemEntity, X.Data"/>
</set>
</class>
</hibernate-mapping>

TranslationItemEntity.hbm.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<import class="X.Data.General.Data.MeasureUnitTranslationItemData, X.Data" />

<class name="X.Data.Translations.Entity.TranslationItemEntity, X.Data"
table="TranslationItems"
discriminator-value="0">

<id name="Id" column="IdTranslationItem" type="Int32" unsaved-value="0">
<generator class="native" />
</id>
<discriminator column="IdTranslationColumn" type="Int32"></discriminator>

<many-to-one name="Language" column="IdLanguage" not-null="true" outer-join="auto"></many-to-one>
<property name="TranslationName" column="TranslationName" type="string" not-null="true"/>
<property name="IdDbRecord" column="IdDbRecord" type="Int32" not-null="true"/>

<subclass name="X.Data.Translations.Entity.MeasureUnitNameTranslationItemEntity, X.Data" discriminator-value="6"></subclass>
<subclass name="X.Data.Translations.Entity.MatrixNameTranslationItemEntity, X.Data" discriminator-value="2"></subclass>
</class>
</hibernate-mapping>

Then my class MeasureUnitNameTranslationItemEntity just extends TranslationItemEntity.

My HQL, that I am trying to execute is
select new MeasureUnitTranslationItemData(mue.Id, mue.Code, ti.TranslationName)
from MeasureUnitEntity mue left join mue.MeasureUnitNameTranslationItemSet ti
where ti.Language.Id = :InputPrmLanguageId

I expect SQL to be:
select
MeasureUnits.IdMeasureUnit,
MeasureUnits.Code,
ti.TranslationName
from
MeasureUnits
left outer join
(select TranslationItems.* from TranslationItems where IdTranslationColumn = 6) AS ti
on MeasureUnits.IdMeasureUnit=ti.IdDbRecord
where
(ti.IdLanguage=20)


But hql produces:
select
MeasureUnits.IdMeasureUnit,
MeasureUnits.Code,
TranslationItems.TranslationName
from
MeasureUnits
left outer join TranslationItems
on MeasureUnits.IdMeasureUnit=TranslationItems.IdDbRecord
where
(TranslationItems.IdLanguage=20)


Is there a bug, or do you have some special advice about the above mapping and hql?
I would really like to know, why the above hql is not working as I predicted.
Thank you!

Lp
Sebastijan


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.