简体   繁体   English

使用休眠多对多连接表中的另一列

[英]One more column into join table using hibernate many-to-many

How i can map structure like this db model http://imagepost.ru/images/186/oefb4v6.png into 我如何将这样的数据库模型http://imagepost.ru/images/186/oefb4v6.png映射到

class A{
    Map<SomeEnum, B> foo;
}

where key in foo is representation of role in a _ has _ b ? 其中FOO关键是 角色的表现_ _ B'

Thanks! 谢谢!

If you want the name of the enum constants in your table column: 如果要在表列中使用枚举常量的名称:

<hibernate-mapping ...>
...
  <typedef name="role" class="org.hibernate.type.EnumType">
    <param name="enumClass">SomeEnum</param>
    <param name="type">12</param>
  </typedef>
...
  <class name="A" table="a">
...
    <map name="foo" table="a_has_b">
      <key column="a_id"/>
      <map-key type="role" length="20" column="role"/>
      <many-to-many class="b" column="b_id"/>
    </set>
...
  </class>
...
  <class name="B">
...
  </class>
...
</hibernate-mapping>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM