Hibernate Tools Eclipse Add-On で Hibernate Code Generation 機能を使用しようとしています。次のエラーが表示されます。
org.hibernate.InvalidMappingException: リソース Alert.hbm.xml からのマッピング ドキュメントを解析できませんでした リソース Alert.hbm.xml からのマッピング ドキュメントを解析できませんでしたプロパティの検索中に: alertId org.hibernate.MappingException: クラス アラートが見つかりません プロパティの検索中に: alertId クラス プロパティの検索中にアラートが見つかりません: alertId java.lang.ClassNotFoundException: アラート アラート
クラス Alert.java が見つかりませんが、コード ジェネレーター (名前の由来は...) がすべての休止状態クラスを生成するはずだと思っていました。
Hibernate Tools 3.4.x で Eclipse Indigo を使用する。
ここに私の hibernate.cfg.xml があります:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<休止状態の構成>
<セッションファクトリー>
<!-- データベース接続設定 -->
<プロパティ名="connection.driver_class">
com.mysql.jdbc.ドライバー
</プロパティ>
<プロパティ名="connection.url">
jdbc:mysql://localhost:3306/findata?tcpKeepAlive=true
</プロパティ>
<property name="connection.username">ルート</property>
<property name="connection.password">madmax1.</property>
<property name="connection.pool_size">2</property>
<property name="show_sql">true</property>
<プロパティ名="方言">
org.hibernate.dialect.mysqldialect
</プロパティ>
<property name="current_session_context_class">スレッド</property>
<プロパティ名="cache.provider_class">
org.hibernate.cache.NoCacheProvider
</プロパティ>
<mapping resource="Alert.hbm.xml" />
<mapping resource="Entity.hbm.xml" />
<mapping resource="FactData.hbm.xml" />
<mapping resource="TimeEvent.hbm.xml" />
<mapping resource="User.hbm.xml" />
<mapping resource="AlertTarget.hbm.xml" />
<mapping resource="LogAlert.hbm.xml" />
</セッションファクトリー>
</休止状態の構成>
Alert.hbm.xml は次のとおりです。
<?xml バージョン="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<休止状態のマッピング>
<class name="Alert" table="alerts">
<id name="alertId" column="id">
<generator class="assigned"/>
</id>
<property name="limitValue" column="limit_value" type="decimal" />
<!-- unique=true プロパティにより、多対 1 が 1 対 1 の関係になります -->
<多対一の名前="alertEntity"
class="Entity" column="entity_id"
not-null="true" カスケード="all" unique="true"/>
<set name="alert_targets" table="alerts_alert_targets" cascade="all">
<key column="alert_id" />
<多対多列="alert_target_id"
class="AlertTarget" />
</セット>
</クラス>
</hibernate-mapping>