I’m trying to build a OneToMany association between the conversation entity and the sms entity.
I want the foreign key to be on the conversation table.
Table_Conversation - id BIGINT - sms_id BIGINT FK REFERENCES SmsBean.id
Here is the Conversation class
public class Conversation{
//...
@OneToMany(targetEntity=SmsBean.class, table="conversation")
public List getSmsList() {
return smsList;
}
}
Note that, I don’t want conversation field in the Sms class as I don’t need it.
Hibernate is not able to generate my tables and throws the following exception:
org.hibernate.cfg.NotYetImplementedException: Collections having FK in secondary table
I’m using Hibernate 3.5 / JPA2.0
Can you help figure out how to do this.
Thanks
This question which is mine, is incorrect.
I want the foreign key to be on the conversation table.
But what would happen when the same conversation(id=123) has two sms? This will lead to two rows with the same id.
So I abandoned this idea and now I’m using a join table as this the hibernate recommended way.