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.
|