Youtube Channel

compostite id

Like in SQL we use composite keys in place of primary keys in hibernate <composite-id> is used
  • It is the combination of two and more columns which behaves likes primary key. If we want to work with this feature we have to make class serializable (implements java.io.Serializable)
  • Syntax:
 Note:
Here <key-property> is used for the columns which are to be included as composite keys.
Example:Demo.hbm.xml


Demo.java(pojo class)