-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping properties without columns in other table.
PostPosted: Thu Feb 02, 2006 12:01 pm 
Newbie

Joined: Thu Feb 02, 2006 11:48 am
Posts: 1
Hi all,
I've got a small question which gives a real headache...
i've got 2 tables, say A and B.
A has an ID and NAME
B has an ID and A_ID which is a foreign key to A

now i've create an object named B_OBJ and i wanna hold in it ID, A_ID and NAME (which should comes from A table..)
does anyone knows how to do that?
I've tried using formula and join and no success (probably doing something wrong..)

any help will be appriciated..
Y.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 12:08 pm 
Beginner
Beginner

Joined: Thu Apr 14, 2005 11:39 am
Posts: 31
You should have someting like this in your mapping file.

<!-- bi-directional many-to-one association to Table A-->
<many-to-one
name="TABLEA"
class="com.xxx.TableA"
not-null="true"
>
<meta attribute="use-in-equals">true</meta>
<meta attribute="field-description">
@hibernate.many-to-one
not-null="true"
@hibernate.column name="A_ID"
</meta>
<column name="A_ID" />
</many-to-one>

And your pojo will have an private attribute of class com.xxx.TableA and a get and set method.

Hope this helps.

Thanks
Sudhakar


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