-->
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: Mapping foreign key reference
PostPosted: Sat Aug 30, 2008 6:37 am 
Newbie

Joined: Sat Aug 30, 2008 6:22 am
Posts: 2
Hi,

I am new to hibernate.I want to know about mapping a relation between two objects[foreign key].
I just need to know conceptually , how its done. I am not posting the actual code.In case if I get into any problem implementing it , I will post the entire stuff.

This is my scenario.
I have 2 bean class , say Library.java,Book.java.
both has a common field called Id.
In my Library.java , I have methods like

setBook(Book book);
getBook();

now I to need create a mapping from library to Book where my Book id is the foreign key and my Library id is the primary key.

This is just an example.So take it as a library contains only one book![:)]


I tried mapping from Book to Library.
I got it done using the <many-to-one> tag, but it requires something like setLibrary(Library lib) in my book.Unfortunately this is against my current design structure and noway that is alowed.

Then,how to form a relation from Library to book?

Thanks in advance for your suggestions.

Thank you,
Vaisakh.


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.