Which Hibernate ( or NHiberate) tags and/or mapping classes would I use to create mappings to the bridge table called contract?

StackOverflow https://stackoverflow.com/questions/15588749

Question

Let's say I have a bridge table with more than two foreign keys that make up it's composite key.

For Example,

Goverment table gov_id int primary key cournty_name String

NonProfitOrg Table nonProfit_id int primary key NonProfit_name String

CommericalFirm Table commercial_id int primary key commerical_name String

( bridge table Called Contract ) Contract gov_id nonProfit_id commercial_id

Which Hibernate ( or NHiberate) tags or mapping classes would I use to create mappings to the bridge table called contract?
Should I create a separate mapping class for the bridge table Called Contract? Or Could we do this with the many-to-many tag in the Government mapping table and NonProfitOrg table and CommericalFirm Table? Please tell me the best approach.

Was it helpful?

Solution

Since you have functional data, other than just the foreign keys to the linked entities, in the contract table, then you need to map it as an entity.

You would thus have a OneToMany between Government and Contract, and another OneToMany between NonProfitOrg and Contract.

And since it's a regular entity, I strongly advise you to identify it with an autogenerated, single-column ID, just like the other entities.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top