I have a simple Spring-Hibernate application.
I have 3 classes crop, market and farmer with structure something like :
class crop
{
private int cropId;
}
class market
{
private int marketId;
}
class farmer
{
private Crop crop;
private Market market;
}
farmer table has a composite key{cropid, marketid}.
Now, how do I map this relationship with composite key element cropid and marketid referencing to crop and market table respectively in the .hbm.xml file .
I am quite new to hibernate and spring. Any suggestions will be of great help !!
In the farmer.hbm.xml you need to make a
composite-idlike thisand write a class
FarmerIDthat implementsSerializableand overridesequals()andhashCode()In
equals()you test if the Objects are the same or have the same values and return a boolean. InhashCode()you generate a hash value and return it.