Hibernate 4 - What should replace deprecated @MapKey to map a Map collection while Key is a customized Hibernate UserType

后端 未结 1 614
鱼传尺愫
鱼传尺愫 2020-12-22 06:30

Considering the following two tables:

| User      | UserAttribute     |
|---------- |-------------------|
| userId(PK)| attributeId(PK)   |
| firstName | use         


        
相关标签:
1条回答
  • 2020-12-22 07:11

    First of all, it should replace MapKeyType(Hibernate) with MapKeyClass(JPA) or just remove it since Hibernate will auto detect.

    And MapKeyJoinColumns/MapKeyJoinColumn will be skipped in this case, refer to the JPA document https://docs.oracle.com/javaee/6/api/javax/persistence/MapKeyJoinColumn.html I guess they're used for entity only.

    The exception means key UserType's column number is not the same with the key column. I can't find @MapKeyColumns but I tried @MapKeyColumn(name="id") and make AttributeKeyHbm only has "id" and it works. So all is to find the MapKeyColumns-like annotation.

    0 讨论(0)
提交回复
热议问题