views:

51

answers:

1

Hi! How i can map structure like this db model into

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

where key in foo is representation of role in a_ has _b ?

Thanks!

+1  A: 

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>
Maurice Perry