难道这不是你所需要的?
为了详细说明轻率的初始响应,该参考资料提供了一种使用枚举的序号映射枚举的方法。
在这种情况下,它实际上比看起来简单,因为您要在集合中托管枚举,因此需要为WicketType提供IntEnumUserType子类型的访问器,超类型将负责将序数映射到实例。
package test;public class WicketTypeState extends IntEnumUserType<WicketType> { private WicketType wicketType;public WicketTypeState() { // we must give the values of the enum to the parent. super(WicketType.class, WicketType.values());} public WicketType getWicketType() { return wicketType; } public void setWicketType(final WicketType wicketType) { this.wicketType = wicketType; }}定义枚举表的映射:
<hibernate-mapping package="test"> <class name="Wicket" table="Wicket"> <id name="id" column="ID"/> <set name="wicketTypes" table="WicketType" inverse="true"> <key column="ID"/> <one-to-many /> </set> </class></hibernate-mapping>
然后为具有枚举集的类型定义该属性的集映射:
<hibernate-mapping package="test"> <class name="WicketTypeState" lazy="true" table="WicketType"> <id name="WicketType" type="test.WicketTypeState"/> </class></hibernate-mapping>
这对我的盒子有效(tm),让我知道是否需要更多信息。



