我正在開發Java應用程序使用Java 6和Hibernate 3.6.9庫。我想創建這是密切相關的特定類的枚舉,所以我想將它定義類的一部分:在Hibernate中映射枚舉子類型
package org.mycompany.container;
public class Container{
public enum ContainerType{
SMALL,MEDIUM,BIG
}
private ContainerType _ContainerType;
private Integer _Id;
//Getter and setters
}
然後我要地圖我的容器類在Hibernate配置文件(我不不使用註釋)。所以我有這個XML件(類的包是在休眠映射文件的開頭指定):
<class name="Container" table="tcontainer">
<id name="_Id" column="id">
<generator class="increment" />
</id>
<property name="_ContainerType" column="container_type">
<type name="org.hibernate.type.EnumType">
<param name="enumClass">org.mycompany.container.Container.ContainerType</param>
<param name="type">12</param>
</type>
</property>
</class>
然而,休眠似乎並不承認ContainerType類,我也得到一個ClassNotFoundException。我已經做了幾次這樣的枚舉作爲一個單獨的類。
任何解決方案?彙集你的想法。
你在同一項目中有兩個HBM文件和你的類?因爲它可能是一個依賴項問題 – fGo