hibernate two tables per one entity

后端 未结 5 2008
栀梦
栀梦 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:34

    I know this question was asked long time ago. But I would like to suggest an alternative way, without using any of hibernate things. For those who don't want to use xml configuration.

    Declare an interface with getter and setter methods of commun columns, then make your tow entity classes implement this interface. Leave the mapping annotations in this two entity class as usual, then in your code, you can invoke method of this interface instead.

提交回复
热议问题