-->
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: Column reuse in combination key db design and annotations
PostPosted: Thu Oct 26, 2006 2:32 pm 
Newbie

Joined: Wed Dec 15, 2004 9:45 am
Posts: 7
I have been using hibernate for quite a while and recently am trying to switch over to annotations and have run into a problem / limitation. The database that I am implementing on top of uses combination keys for it's primary keys. While, I know that hibernate prefers a surrogate approach, I don't have that option.

With combination keys, you often have to map a colum multiple times. For instance, you may have a column like ITEM that maps to one property and then that same ITEM column participlates with some other columns to act as a foreign key to another table. Unfortunately, hibernate does not allow you to have the same column name declared in a mapping multiple times.

In the xml mapping syntax, you get arround this by a formula element that simply has the column name. However, this is not possible in the annotations syntax. While the syntax does support an @JoinColumns annotation that allows you to list out all of the @JoinColumn elements in the key, it will not accept an @Formula annotation in the list. Is there another way to work around this?? Or, is there another annotation that I have missed that is used for this purpose?

Thanx,
LES


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.