-->
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: How to define composite key with constant value ?
PostPosted: Thu Nov 06, 2008 9:06 am 
Newbie

Joined: Thu Nov 06, 2008 8:57 am
Posts: 1
Hi

I`m looking for help with my small problem, but I couldn`t find any example in web.

I`ve got two tables

Dictionary
(
key_id number,
dictionary_code string,
key_value string
)
and for example
Product
(
id number,
color_id number,
something..
)

In Dictionary table I have values for many of my dictionares. Unfortunatelly key_id isn`t unique and it can`t be treated as primary key
So row may look like:
1 ; COLOR ; blue
2 ; COLOR ; green
1 ; SIZE ; big

etc

the table Product contains column color_id which references key_id column.
So the question is - how can I define this relation using Hibernate Annotations - so that Product class will have it`s related color value ?

I was trying to define class for that composite key, but i can`t find a way to define a constant value for the dictionary_code field

PS. I can`t change the database structure because it isn`t mine product and idea..

Thanks very very much


Regards


Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


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.