[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2659) Hibernate Not Generating XML Correctly for Joins

Lincoln R. Carr (JIRA) noreply at atlassian.com
Thu Jun 7 13:28:04 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_27172 ] 

Lincoln R. Carr commented on HHH-2659:
--------------------------------------

Oops!  Some of the XML above lost its formatting when I posted.  I don't see a way to edit the original post, so here's the XML with better formatting.

<HicnXref>
    . . .

    <beneMasterByCurrHicn>
        . . .
        <BeneHomeHealths>
            <BeneHomeHealth>
                <id>
                    <hicn>**********</hicn>
                    <occ>1</occ>
                </id>
                <beneMaster>001105005A</beneMaster>
                <recTs>26 April 2007</recTs>
                <startDt>13 April 2006</startDt>
                <endDt>11 June 2006</endDt>
                <ebaDt>13 April 2006</ebaDt>
                <lbaDt>11 May 2006</lbaDt>
                <contractorId>11</contractorId>
                <providerId>107338A</providerId>
                <patientStatusCd>01</patientStatusCd>
            </BeneHomeHealth>
            <BeneHomeHealth>
                <id>
                    <hicn>*********</hicn>
                    <occ>1</occ>
                </id>
                <beneMaster>001105005A</beneMaster>
                <recTs>26 April 2007</recTs>
                <startDt>13 April 2006</startDt>
                <endDt>11 June 2006</endDt>
                <ebaDt>13 April 2006</ebaDt>
                <lbaDt>11 May 2006</lbaDt>
                <contractorId>11</contractorId>
                <providerId>107338A</providerId>
                <patientStatusCd>01</patientStatusCd>
            </BeneHomeHealth>
            <BeneHomeHealth>
                <id>
                    <hicn>*********</hicn>
                    <occ>1</occ>
                </id>
                <beneMaster>001105005A</beneMaster>
                <recTs>26 April 2007</recTs>
                <startDt>13 April 2006</startDt>
                <endDt>11 June 2006</endDt>
                <ebaDt>13 April 2006</ebaDt>
                <lbaDt>11 May 2006</lbaDt>
                <contractorId>11</contractorId>
                <providerId>107338A</providerId>
                <patientStatusCd>01</patientStatusCd>
            </BeneHomeHealth>
            <BeneHomeHealth>
                <id>
                    <hicn>*********</hicn>
                    <occ>2</occ>
                </id>
                <beneMaster>001105005A</beneMaster>
                <recTs>26 April 2007</recTs>
                <startDt>12 April 2005</startDt>
                <endDt>10 June 2005</endDt>
                <ebaDt>12 April 2005</ebaDt>
                <lbaDt>20 May 2005</lbaDt>
                <contractorId>11</contractorId>
                <providerId>107338A</providerId>
                <patientStatusCd>01</patientStatusCd>
            </BeneHomeHealth>
            <BeneHomeHealth>
                <id>
                    <hicn>*********</hicn>
                    <occ>2</occ>
                </id>
                <beneMaster>001105005A</beneMaster>
                <recTs>26 April 2007</recTs>
                <startDt>12 April 2005</startDt>
                <endDt>10 June 2005</endDt>
                <ebaDt>12 April 2005</ebaDt>
                <lbaDt>20 May 2005</lbaDt>
                <contractorId>11</contractorId>
                <providerId>107338A</providerId>
                <patientStatusCd>01</patientStatusCd>
            </BeneHomeHealth>
            <BeneHomeHealth>
                <id>
                    <hicn>*********</hicn>
                    <occ>2</occ>
                </id>
                <beneMaster>001105005A</beneMaster>
                <recTs>26 April 2007</recTs>
                <startDt>12 April 2005</startDt>
                <endDt>10 June 2005</endDt>
                <ebaDt>12 April 2005</ebaDt>
                <lbaDt>20 May 2005</lbaDt>
                <contractorId>11</contractorId>
                <providerId>107338A</providerId>
                <patientStatusCd>01</patientStatusCd>
            </BeneHomeHealth>
            <BeneHomeHealth>
                <id>
                    <hicn>*********</hicn>
                    <occ>3</occ>
                </id>
                <beneMaster>001105005A</beneMaster>
                <recTs>26 April 2007</recTs>
                <startDt>23 April 2004</startDt>
                <endDt>21 June 2004</endDt>
                <ebaDt>23 April 2004</ebaDt>
                <lbaDt>10 May 2004</lbaDt>
                <contractorId>11</contractorId>
                <providerId>107338A</providerId>
                <patientStatusCd>01</patientStatusCd>
            </BeneHomeHealth>
            <BeneHomeHealth>
                <id>
                    <hicn>*********</hicn>
                    <occ>3</occ>
                </id>
                <beneMaster>001105005A</beneMaster>
                <recTs>26 April 2007</recTs>
                <startDt>23 April 2004</startDt>
                <endDt>21 June 2004</endDt>
                <ebaDt>23 April 2004</ebaDt>
                <lbaDt>10 May 2004</lbaDt>
                <contractorId>11</contractorId>
                <providerId>107338A</providerId>
                <patientStatusCd>01</patientStatusCd>
            </BeneHomeHealth>
            <BeneHomeHealth>
                <id>
                    <hicn>*********</hicn>
                    <occ>3</occ>
                </id>
                <beneMaster>001105005A</beneMaster>
                <recTs>26 April 2007</recTs>
                <startDt>23 April 2004</startDt>
                <endDt>21 June 2004</endDt>
                <ebaDt>23 April 2004</ebaDt>
                <lbaDt>10 May 2004</lbaDt>
                <contractorId>11</contractorId>
                <providerId>107338A</providerId>
                <patientStatusCd>01</patientStatusCd>
            </BeneHomeHealth>
        </BeneHomeHealths>
    </beneMasterByCurrHicn>
</HicnXref>

> Hibernate Not Generating XML Correctly for Joins
> ------------------------------------------------
>
>                 Key: HHH-2659
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2659
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.4.sp1
>         Environment: Hibernate 3.2.4.sp1, Oracle 10g 10.2.0.3.0
>            Reporter: Lincoln R. Carr
>
> Using entity mode, with no POJOs, and outer joins, Hibernate appears to generate XML incorrectly.  That is, it seems not to map the query result from the outer join to the output XML correctly.  A snippet from one of the hbm.xml files is as follows:
> .
> .
> .
> <hibernate-mapping>
>     <class
>         entity-name="com.ngsmedicare.ngd.il.data.hibernate.datamart.BeneMaster"
>         table="BENE_MASTER" schema="NDR">
>         <id name="Hicn" type="string">
>             <column name="HICN" length="12" />
>             <generator class="assigned" />
>         </id>
> .
> .
> .
>         <set name="BeneHomeHealths" inverse="true" fetch="join">
>             <key>
>                 <column name="HICN" length="12" not-null="true" />
>             </key>
>             <one-to-many
>                 entity-name="com.ngsmedicare.ngd.il.data.hibernate.datamart.BeneHomeHealth" />
>         </set>
> .
> .
> .
> The generated SQL _is_ correct.  A snippet corresponding to the snippet above is as follows:
> select
> .
> .
> .
>      from
>         NDR.HICN_XREF hicnxref0_ 
>     inner join
>         NDR.BENE_MASTER benemaster1_ 
>             on hicnxref0_.CURR_HICN=benemaster1_.HICN 
> .
> .
> .
>     left outer join
>         NDR.BENE_HOME_HEALTH benehomehe9_ 
>             on benemaster1_.HICN=benehomehe9_.HICN 
>     where
>         hicnxref0_.SEARCH_HICN=?
> However, the generated XML is _not_ correct.  A section is as follows:
> <HicnXref>
> .
> .
> .
> 	<beneMasterByCurrHicn>
> .
> .
> .
> 		<BeneHomeHealths>
> 			<BeneHomeHealth>
> 				<id>
> 					<hicn>**********</hicn>
> 					<occ>1</occ>
> 				</id>
> 				<beneMaster>001105005A</beneMaster>
> 				<recTs>26 April 2007</recTs>
> 				<startDt>13 April 2006</startDt>
> 				<endDt>11 June 2006</endDt>
> 				<ebaDt>13 April 2006</ebaDt>
> 				<lbaDt>11 May 2006</lbaDt>
> 				<contractorId>11</contractorId>
> 				<providerId>107338A</providerId>
> 				<patientStatusCd>01</patientStatusCd>
> 			</BeneHomeHealth>
> 			<BeneHomeHealth>
> 				<id>
> 					<hicn>*********</hicn>
> 					<occ>1</occ>
> 				</id>
> 				<beneMaster>001105005A</beneMaster>
> 				<recTs>26 April 2007</recTs>
> 				<startDt>13 April 2006</startDt>
> 				<endDt>11 June 2006</endDt>
> 				<ebaDt>13 April 2006</ebaDt>
> 				<lbaDt>11 May 2006</lbaDt>
> 				<contractorId>11</contractorId>
> 				<providerId>107338A</providerId>
> 				<patientStatusCd>01</patientStatusCd>
> 			</BeneHomeHealth>
> 			<BeneHomeHealth>
> 				<id>
> 					<hicn>*********</hicn>
> 					<occ>1</occ>
> 				</id>
> 				<beneMaster>001105005A</beneMaster>
> 				<recTs>26 April 2007</recTs>
> 				<startDt>13 April 2006</startDt>
> 				<endDt>11 June 2006</endDt>
> 				<ebaDt>13 April 2006</ebaDt>
> 				<lbaDt>11 May 2006</lbaDt>
> 				<contractorId>11</contractorId>
> 				<providerId>107338A</providerId>
> 				<patientStatusCd>01</patientStatusCd>
> 			</BeneHomeHealth>
> 			<BeneHomeHealth>
> 				<id>
> 					<hicn>*********</hicn>
> 					<occ>2</occ>
> 				</id>
> 				<beneMaster>001105005A</beneMaster>
> 				<recTs>26 April 2007</recTs>
> 				<startDt>12 April 2005</startDt>
> 				<endDt>10 June 2005</endDt>
> 				<ebaDt>12 April 2005</ebaDt>
> 				<lbaDt>20 May 2005</lbaDt>
> 				<contractorId>11</contractorId>
> 				<providerId>107338A</providerId>
> 				<patientStatusCd>01</patientStatusCd>
> 			</BeneHomeHealth>
> 			<BeneHomeHealth>
> 				<id>
> 					<hicn>*********</hicn>
> 					<occ>2</occ>
> 				</id>
> 				<beneMaster>001105005A</beneMaster>
> 				<recTs>26 April 2007</recTs>
> 				<startDt>12 April 2005</startDt>
> 				<endDt>10 June 2005</endDt>
> 				<ebaDt>12 April 2005</ebaDt>
> 				<lbaDt>20 May 2005</lbaDt>
> 				<contractorId>11</contractorId>
> 				<providerId>107338A</providerId>
> 				<patientStatusCd>01</patientStatusCd>
> 			</BeneHomeHealth>
> 			<BeneHomeHealth>
> 				<id>
> 					<hicn>*********</hicn>
> 					<occ>2</occ>
> 				</id>
> 				<beneMaster>001105005A</beneMaster>
> 				<recTs>26 April 2007</recTs>
> 				<startDt>12 April 2005</startDt>
> 				<endDt>10 June 2005</endDt>
> 				<ebaDt>12 April 2005</ebaDt>
> 				<lbaDt>20 May 2005</lbaDt>
> 				<contractorId>11</contractorId>
> 				<providerId>107338A</providerId>
> 				<patientStatusCd>01</patientStatusCd>
> 			</BeneHomeHealth>
> 			<BeneHomeHealth>
> 				<id>
> 					<hicn>*********</hicn>
> 					<occ>3</occ>
> 				</id>
> 				<beneMaster>001105005A</beneMaster>
> 				<recTs>26 April 2007</recTs>
> 				<startDt>23 April 2004</startDt>
> 				<endDt>21 June 2004</endDt>
> 				<ebaDt>23 April 2004</ebaDt>
> 				<lbaDt>10 May 2004</lbaDt>
> 				<contractorId>11</contractorId>
> 				<providerId>107338A</providerId>
> 				<patientStatusCd>01</patientStatusCd>
> 			</BeneHomeHealth>
> 			<BeneHomeHealth>
> 				<id>
> 					<hicn>*********</hicn>
> 					<occ>3</occ>
> 				</id>
> 				<beneMaster>001105005A</beneMaster>
> 				<recTs>26 April 2007</recTs>
> 				<startDt>23 April 2004</startDt>
> 				<endDt>21 June 2004</endDt>
> 				<ebaDt>23 April 2004</ebaDt>
> 				<lbaDt>10 May 2004</lbaDt>
> 				<contractorId>11</contractorId>
> 				<providerId>107338A</providerId>
> 				<patientStatusCd>01</patientStatusCd>
> 			</BeneHomeHealth>
> 			<BeneHomeHealth>
> 				<id>
> 					<hicn>*********</hicn>
> 					<occ>3</occ>
> 				</id>
> 				<beneMaster>001105005A</beneMaster>
> 				<recTs>26 April 2007</recTs>
> 				<startDt>23 April 2004</startDt>
> 				<endDt>21 June 2004</endDt>
> 				<ebaDt>23 April 2004</ebaDt>
> 				<lbaDt>10 May 2004</lbaDt>
> 				<contractorId>11</contractorId>
> 				<providerId>107338A</providerId>
> 				<patientStatusCd>01</patientStatusCd>
> 			</BeneHomeHealth>
> 		</BeneHomeHealths>
> 	</beneMasterByCurrHicn>
> </HicnXref>
> The <hicn> field values have been replaced with asterisks because of privacy concerns.  If one executes the SQL above, the result has 9 rows total.  However, the table correspondding to the <BeneHomeHealth> elements only has three pertinent entries, indicated by the <occ> element.  Hibernate seems to be dealing with the Cartesian product incorrectly, generating "extra" entries in the XML.  In the above XML, each <BeneHomeHealth> element is repeated 3 times when it should only be included once.  One should note that the <BeneHomeHealth> elements with the same <occ> value are identical.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list