-->
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.  [ 4 posts ] 
Author Message
 Post subject: hibernate xdoclet with composite-id problem?
PostPosted: Wed Jan 21, 2004 1:15 pm 
Newbie

Joined: Thu Jan 15, 2004 3:12 pm
Posts: 4
Hi, I have a mapping as follows. How do I get xdoclet to generate "key-property" and "key-many-to-one" inside a composite-id?
Code:
<composite-id name="compoundPrimaryKey" class="com.retek.rib.domain.ribmessage.bo.impl.RibMessageHospitalRefPrimaryKeyImpl" unsaved-value="any">
        <key-property
            name="seqNumber"
            column="SEQ_NUMBER"
            type="short"
            length="2"
        />
        <!-- bi-directional many-to-one association to RibMessage -->
        <key-many-to-one
           name="ribMessage"
           class="com.retek.rib.domain.hospital.bo.impl.HospitalEntryImpl"
       >
           <column name="MESSAGE_NUM" />
      </key-many-to-one>
</composite-id>



Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 1:28 pm 
From what I have seen in the XDoclet documentation, composite primary keys are not supported.


Top
  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 1:47 pm 
Newbie

Joined: Thu Jan 15, 2004 3:12 pm
Posts: 4
I am looking at hibernate.xdt, and it seems like it has code for composite-id and "key-property". Can someone throw some light.

Code:
<XDtHibernate:ifHasCompositeId>
        <composite-id
            name="<XDtMethod:propertyName/>"
            class="<XDtMethod:methodTagValue tagName="hibernate.id" paramName="class" default="<XDtMethod:methodType/>"/>"
            <XDtMethod:ifHasMethodTag tagName="hibernate.id" paramName="unsaved-value">
            unsaved-value="<XDtMethod:methodTagValue tagName="hibernate.id" paramName="unsaved-value" values="any,none"/>"
            </XDtMethod:ifHasMethodTag>
        >
        <XDtClass:pushClass value="<XDtMethod:methodType/>">
            <XDtMethod:forAllMethods superclasses="true" sort="true">
                 <XDtMethod:ifHasMethodTag tagName="hibernate.property">
                     <key-property
                        name="<XDtMethod:propertyName />"
                        type="<XDtMethod:methodTagValue tagName="hibernate.property" paramName="type" default="<XDtMethod:methodType/>"/>"
                        column="<XDtMethod:methodTagValue tagName="hibernate.property" paramName="column" default="<XDtMethod:propertyName/>"/>"
                       <XDtMethod:ifHasMethodTag tagName="hibernate.property" paramName="length">
                        length="<XDtMethod:methodTagValue tagName="hibernate.property" paramName="length" />"
                       </XDtMethod:ifHasMethodTag>
                />
                </XDtMethod:ifHasMethodTag>

                <XDtMethod:ifHasMethodTag tagName="hibernate.many-to-one">
                    <key-many-to-one
                        name="<XDtMethod:propertyName/>"
                        class="<XDtMethod:methodTagValue tagName="hibernate.many-to-one" paramName="class" default="<XDtMethod:methodType/>" />"
                        column="<XDtMethod:methodTagValue tagName="hibernate.many-to-one" paramName="column" default="<XDtMethod:propertyName/>"/>"
                    />
                </XDtMethod:ifHasMethodTag>
            </XDtMethod:forAllMethods>
        </XDtClass:pushClass>
        </composite-id>
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 7:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Composite IDs in XDoclet is only supported when using an external class for the key. So you will be able to XDoclet generate your mapping. Most of the Xdoclet markup is on the Keys Class, eg, the field properties. The persistant class will have the ID with property reference to the key class.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.