-->
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: column ambiguously defined
PostPosted: Mon Aug 29, 2011 7:50 am 
Newbie

Joined: Wed Jul 08, 2009 3:16 am
Posts: 2
Hi,
Given the following Model Objects:
Absence, 2 subclasses: WAAbsence & PIAbsence
Expertise, 2 subclasses: WAExpertise & PIExpertise

a WAAbsence can have max 1 WAExpertise
a PIAbsence can have max 1 PIExpertise

Mapping:
Code:
   <class name="Absence" table="ABSENCE" discriminator-value="ABS">
        <id name="id" type="long" column="ID" >
            <generator class="native">
                <param name="sequence">SEQ_ABSENCE</param>
            </generator>
        </id>
        <discriminator column="DISCRIMINATOR" />
        <subclass name="WAAbsence" discriminator-value="WA">
            <many-to-one name="expertise" column="WA_EXPERTISE_ID" class="WAExpertise"/>
            <property name="accidentDate" column="ACCIDENT_DT" type="date" not-null="false" />           
        </subclass>
       
        <subclass name="PIAbsence" discriminator-value="PI">
            <many-to-one name="expertise" column="PI_EXPERTISE_ID" class="PIExpertise"/>
            <property name="declarationDate" column="PI_DECL_DT" type="date" not-null="false" />
        </subclass>
    </class>


Absences are saved in 1 table:
ABSENCE(ID, DISCRIMINATOR, WA_EXPERTISE_ID, PI_EXPERTISE_ID, ACCIDENT_DT, PI_DECL_DT, ...)

Expertises in 2 tables:
WA_EXPERTISE & PI_EXPERTISE

When using searchcriteria to find certain absences, hibernate generates the following code:

Code:
select
            this_.ID as y0_,
            p2_.FIRST_NAME as y1_,
            p2_.LAST_NAME as y2_,
            md4_.MEDICAL_NUMBER as y3_,
            this_.NUMBER_OF_DAYS as y4_,
            this_.START_DT as y5_,
            c1_.END_DT as y6_,
            this_.DISCRIMINATOR as y7_,
            c1_.ID as y8_,
            e3_.ID as y9_,
            this_.APPROVED as y10_
        from
            ABSENCE this_
        left outer join
            CONTRACT c1_
                on this_.CONTRACT_ID=c1_.ID
        left outer join
            PERSON p2_
                on c1_.PERSON_ID=p2_.ID
        left outer join
            DOSSIER md4_
                on p2_.ID=md4_.PERSON_ID
        left outer join
            CODE type5_
                on md4_.DOSSIER_TYPE_CD=type5_.ID
        left outer join
            CODE s6_
                on this_.STATUS_CD=s6_.ID
        left outer join
            WA_EXPERTISE e3_
                on this_.WA_EXPERTISE_ID=e3_.ID
        left outer join
            PI_EXPERTISE e3_
                on this_.PI_EXPERTISE_ID=e3_.ID
        where
            type5_.CODE='A'
            and p2_.FIRST_NAME like 'x'
        order by
            this_.START_DT asc


Any tips on how to fix the duplicate naming (e3_) in the above?

Thanks in advance

(Using Oracle 10g & Hibernate 3.2.6)


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.