-->
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.  [ 6 posts ] 
Author Message
 Post subject: Composite Ids
PostPosted: Mon Aug 29, 2005 10:49 am 
Beginner
Beginner

Joined: Tue Aug 23, 2005 4:59 pm
Posts: 31
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3


Im using The 3.1 alpha 5 release of the Hibernate Tools for Eclipse, and found that in java code generation (POJO) files it creates a new class for the coposite ids. Is this the best way to do this? Why not just create one POJO with the ids in the same class?

Thanks still learning!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 29, 2005 1:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh - what?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 29, 2005 1:29 pm 
Beginner
Beginner

Joined: Tue Aug 23, 2005 4:59 pm
Posts: 31
So in the tools if you have a table that has a composite key say column a b with more columns c d e f....


It creates the mapping in the following way..

<class name="tableclass" table="alphabet" >
<composite-id name="id" class="alphabetId">
<key-property name="a" type="string"/>

</key-property>
<key-property name="b" type="string">

</key-property>
</composite-id>
<property name="c" type="string">
<property name="d" type="string">
<property name="e" type="string">
</class>

Thus two classes... why not leave the coposite id in the same class?
ie

<composite-id >
<key-property name="a" type="string"/>

</key-property>
<key-property name="b" type="string">

</key-property>
</composite-id>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 29, 2005 1:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Matter of taste and because having it as a separate class is much much easier generation wise ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 29, 2005 2:00 pm 
Beginner
Beginner

Joined: Tue Aug 23, 2005 4:59 pm
Posts: 31
Is there any reason for hibernate to have it that way? Perfomance etc?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 29, 2005 2:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no - its just one way to do it (I don't like it, but that doesnt mean it isn't good for others)

_________________
Max
Don't forget to rate


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