I searched a lot in google but i didn't find any satisfied answer. So any one any please tell me a senario, where to use natural-id in hbm file in hibernate. Any help would be greatly appreciated.
Thanks in advance.....
You are strongly encouraged to use a surrogate primary key on your tables, i.e. a column called id which is not derived from the business data. However there is most likely a combination of fields which form a sensible business key for a table. These fields should be non-null and immutable. This is what would be marked as the natural key and would also be used in the equals and hashCode implementations for that class.
If Hibernate were to generate your database schema from your mapped domain classes this natural key would be used to generate a unique index for the table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With