-->
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: composite keys mapping using xdoclet
PostPosted: Mon Oct 25, 2004 9:59 pm 
Newbie

Joined: Thu May 20, 2004 5:40 pm
Posts: 10
Location: Rio de Janeiro - Brazil
Hello!
Is there a way to perform composite keys mapping using xdoclet?
I can't find anything about.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 27, 2004 7:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Yes - put the field markup into the composite key class on the key properties. Integrated composite keys are not supported (atleast the last time I looked at it).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 03, 2004 7:03 am 
Senior
Senior

Joined: Wed Aug 27, 2003 4:08 am
Posts: 178
Location: Wiesbaden, Germany
david wrote:
Yes - put the field markup into the composite key class on the key properties. Integrated composite keys are not supported (atleast the last time I looked at it).


Hi Gavin,
I read it in dtd that:

"A composite key may be modelled by a java class with a property for each
key column. The class must implement java.io.Serializable and reimplement equals()
and hashCode()."

How do we implement integrated key? Declare class properties to
key properties?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 03, 2004 7:40 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Example of integrated composite keys (Doco) which is not the recommended approach:

Code:
For a table with a composite key, you may map multiple properties of the class as identifier properties. The <composite-id> element accepts <key-property> property mappings and <key-many-to-one> mappings as child elements.

<composite-id>
        <key-property name="medicareNumber"/>
        <key-property name="dependent"/>
</composite-id>

Your persistent class must override equals() and hashCode() to implement composite identifier equality. It must also implements Serializable.

Unfortunately, this approach to composite identifiers means that a persistent object is its own identifier. There is no convenient "handle" other than the object itself.


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.