Hi, I am new to hibernate and I have studied online materials on Hibernate. But I havent understood how to write a mapping file for the following scenaria. Please help...
I have two classes Country and State...
Country (int countryID, String countryName, String description);
State (int stateID, String stateName, Country country, String description);
And the tables are:
COUNTRY:
Integer COUNTRY_ID --> PK
Varchar COUNTRY_NAME
Varchar DESCRIPTION
STATE:
Integer STATE_ID --> PK
Varchar STATE_NAME
Integer STATE_COUNTRY_ID (FK to country's COUNTRY_ID)
Varchar DECSRIPTION
I am able to persist Country without any problem as it is quite straight forward without any foreign key relations. But I haven't figured a way to write a mapping file for State that has Country object in it.
Please provide me mapping file for State.class
Thanks
Sanskruti.
|