Composite Key in JPA / Hibernate with inherited class

后端 未结 3 1801
臣服心动
臣服心动 2021-02-04 18:12

i have a composite id defined on my class structure as below. Unfortunatly i always get a hibernate error that complains on the not found \"part2\":

\"Property of @IdCla

3条回答
  •  滥情空心
    2021-02-04 19:08

    From the JPA spec:

    The primary key must be defined on the entity class that is the root of the entity hierarchy or on a mapped superclass that is a (direct or indirect) superclass of all entity classes in the entity hierarchy. The primary key must be defined exactly once in an entity hierarchy.

    So according to JPA you can't redefine the @Id. I wouldn't call this a bug.

    Although the workaround given as answer here might work, it may happen that for other JPA frameworks it doesn't work.

提交回复
热议问题