Search code examples
hibernate-mapping

what type of hiberante mapping should be used


I have one table called order and another table called order type: one order may have or may not have secondary order and this orders may have or may not have order types,what type of mapping to use in hibernate?


Solution

  • Based on your requirement Order table may or may not contain OrderType. So if order has one or many OrderTypes then One to many relation from OrderType table to Order (i.e from Order to OrderType table many to one relation). If the Order table may not contain OrderType then in Order table make foreign key default null.