-->
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: Simple Legacy Map for Beginner
PostPosted: Tue Aug 18, 2009 6:54 pm 
Newbie

Joined: Tue Aug 18, 2009 6:28 pm
Posts: 1
I must be missing something simple, but everything I tried, especially property-ref, did not work, and I don't want to resort to a formula.

I have 2 tables, Report and Image, that have no constraints whatsoever. But there is a 1-1 relationship: for each record in Report there exist only one in Image, and I wish to specify this <one-to-one> mapping.

Report's composite key is (e.g.) a,b,c,d, and Image's composite key is (e.g.) a,b,c. Field 'd' is, for practical purposes of my application, a constant. It is nonetheless part of the primary key.

This should be simple. Can someone explain what I'm overlooking? Can someone else point me to the tutorial or reference in which this concept is covered?

Thanks for your help

Here's a snippet of my report.hbm.xml and image.hbm.xml:
Code:

<!-- report.hbm.xml -->

    <class name = "Report" <!-- ... -->   >
        <composite-id
            mapped = "true"
            class = "ReportCompositeKey">

            <key-property name = "settleControlCode" type="string">
                <column name = "SETTLE_CONTROL_NUMBER" sql-type = "varchar2"
                        length = "10" not-null = "true"/>
            </key-property>

            <key-property name = "invoiceCode" type="string">
                <column name = "INVOICE"
                        sql-type = "varchar2"
                        length = "16"
                        not-null = "true" />
            </key-property>

            <key-property name = "salesId" type="java.lang.Long">
                <column name = "SALES_ID"
                        sql-type = "number"
                        length = "10"
                        not-null = "true"/>
            </key-property>

            <key-property name = "xtekReportType" type="int" >
                <column name = "XTEK_REPORT_TYPE"
                        sql-type = "number"
                        length = "5"
                        not-null = "true"/>
            </key-property>

            <key-property name = "xtekReportNumber" type="int">
                <column name = "XTEK_REPORT_NUMBER"
                        sql-type = "number"
                        length = "5"
                        not-null = "true"/>
            </key-property>

            <key-property name = "xtekTimestamp" type="timestamp">
                <column name = "XTEK_TIME_STAMP"
                        sql-type = "date"
                        length = "7"
                        not-null = "true"/>
            </key-property>

            <key-property name = "scanned" type="string">
               <column name = "PAPER_SCANNED" sql-type = "char" length = "1"
                       not-null = "true"/>
            </key-property>

        </composite-id>

        <!-- ... -->
    </class>

<!-- image.hbm.xml -->

    <class name = "Image" <!-- ... --> >

        <composite-id
            mapped = "true"
            class = "ImageCompositeKey">

            <key-property name = "settleControlCode" type="string">
                <column name = "SETTLE_CONTROL_NUMBER" sql-type = "varchar2"
                        length = "16" not-null = "true"/>
            </key-property>

            <key-property name = "invoiceCode" type="string">
                <column name = "DOCUMENT_NUMBER" sql-type = "varchar2" length = "16"
                        not-null = "true"/>
            </key-property>

            <key-property name = "salesId" type="java.lang.Long" >
                <column name = "IDENTIFIER_CODE" sql-type = "number" length = "10"/>
            </key-property>

            <key-property name = "xtekReportType" type="int">
                <column name = "REPORT_TYPE" sql-type = "number" length = "5"
                        not-null = "true"/>
            </key-property>

            <key-property name = "xtekReportNumber" type="int">
                <column name = "REPORT_NUMBER" sql-type = "number" length = "10"/>
            </key-property>

            <key-property name = "xtekTimestamp" type="timestamp">
                <column name = "TIME_STAMP" sql-type = "date" length = "7"/>
            </key-property>

        </composite-id>

        <!-- ... -->
    </class>



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.