hibernate two tables per one entity

后端 未结 5 2010
栀梦
栀梦 2020-12-01 05:31

I have one entity - User. It is described by User.class.

Hibernate creates one table per entity, so when I call session.save(user)

5条回答
  •  时光说笑
    2020-12-01 06:33

    Although i have never used but there is a concept of Secondary Table in hibernate. And @SecondaryTables is the annotation in hibernate by which an entity can map more than one table to fetch the data. The entity which is fetching data should have @SecondaryTables annotations. It associates secondary table on the basis of primary and foreign key and also on the basis of unique constrains.

    Here is one sample I found after doing google, check whether it helps you to achieve :

    http://www.concretepage.com/hibernate/secondarytables_hibernate_annotation.php

提交回复
热议问题