Hibernate extend entity for same table

前端 未结 5 1133
猫巷女王i
猫巷女王i 2021-02-05 22:32

I have a table with two fields I would like to have two objects.

First one only has field1

@Entity(name = \"simpleTableObject\")
@Table(name = \"someTabl         


        
5条回答
  •  忘掉有多难
    2021-02-05 23:20

    Good question, I assume you have to look at @MappedSuperclass anotation. It allows to make an "abstract" entity class that would not be instantiated, however you can extend from that.

    See example of that here

    Update: Since you use @Entity anotation, you dont have to use @Table since Hibernate will create table named @Entity for you.

提交回复
热议问题