-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mapping a attribute as a foreign key
PostPosted: Fri Feb 27, 2004 10:25 am 
Regular
Regular

Joined: Thu Feb 05, 2004 6:51 am
Posts: 50
Hi,

I have a class containing a string attribute state and I want this attribute to be mapped in another table than the one of this class.

Example:
Class A
id : float
state : string

Table A
id
state

Table B
id
name

My problem comes from the fact that there is no class State in the app, but I have to use the table B which contains possible values for state name.

I want the attribute state of the class A mapped to the attribute state of the table A but this last one must be a foreign key referencing name in table B.

What is the mapping to use for that?

Vlad


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2004 10:42 am 
Regular
Regular

Joined: Thu Feb 05, 2004 6:51 am
Posts: 50
I guess a component mapping is not appropriate since there is no class referenced by the state attribute in the object model and for the one-to-one, that is the same?

Vlad


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2004 10:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
This is not really supported. You could try mapping it as a private Set, with a <element> refering to your associated table, then add a public get/set which will delegate to the first element of the set.

This will probably get easier in future versions with the <join> element.


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