开发者

Hibernate component

开发者 https://www.devze.com 2023-02-16 21:01 出处:网络
I need to migrate some hibernate hbm files to JPA/Hibernate annotations. The existing relationship is as follows -

I need to migrate some hibernate hbm files to JPA/Hibernate annotations. The existing relationship is as follows -

  1. The parent class has an ID
  2. The component class also has an ID

The 2 identifiers refer to different sequences.

I have used @Embedded and开发者_运维技巧 @AttributeOverride in the parent class, and @Embeddable in the component class.

Both the classes are entities.

The exception i get when i try to save a parent class object is -

org.hibernate.MappingException: component property not found: id

I suppose the exception is because i have 2 identifiers defined.

Any suggestions/workarounds on this will help greatly.


You can't make something an @Entity and @Embeddable at the same time, that makes no sense. You have to make it one or the other.

If both have an ID, and both are entities, then the Hibernate/JPA component/embeddable model doesn't apply.

0

精彩评论

暂无评论...
验证码 换一张
取 消