何らかの理由で、Hibernate が私のクラスの 1 つで Getter を認識していないか、少なくともそれが起こっていると思います。休止状態のマッピング ファイルまたは別の XML 構成ファイルに何か間違った設定がありますか?
お見せしているコードは WaveMaker によって生成されたもので、動作するはずです。単純な HQL クエリを実行しようとしていますが、常に次のエラーが発生します。クエリがどれほど単純であるか、クエリするエンティティが何であるかは問題ではありません。常に「ゲッターが見つかりませんでした」というエラーが発生します。
インストール中にダウンロードするHibernateとSpringのバージョンに関係なく、WaveMaker 6.5を使用しています。
これが私が得るエラーです:
Run query error: Error creating bean with name 'm2mex2DBDataService' defined in
resource loaded through SAX InputSource: Cannot resolve reference to bean
'm2mex2DBHibernateTemplate' while setting constructor argument; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'm2mex2DBHibernateTemplate' defined in resource loaded through SAX InputSource: Cannot
resolve reference to bean 'm2mex2DBSessionFactory' while setting bean property
'sessionFactory'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'm2mex2DBSessionFactory' defined in resource loaded through SAX InputSource: Invocation
of init method failed; nested exception is org.hibernate.PropertyNotFoundException:
Could not find a getter for bookauthors in class com.m2mex2db.data.Author
Author クラスのコードは次のとおりです。
package com.m2mex2db.data;
import java.util.HashSet;
import java.util.Set;
/**
* m2mex2DB.Author
* 05/08/2013 16:33:50
*
*/
public class Author {
private Integer id;
private String firstname;
private String lastname;
private Set<com.m2mex2db.data.Bookauthor> bookauthors = new HashSet<com.m2mex2db.data.Bookauthor>();
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public Set<com.m2mex2db.data.Bookauthor> getBookauthors() {
return bookauthors;
}
public void setBookauthors(Set<com.m2mex2db.data.Bookauthor> bookauthors) {
this.bookauthors = bookauthors;
}
}
そして、これが私のHibernateマッピングファイルです:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.m2mex2db.data.Author" table="author" schema="kentoj" dynamic-insert="false" dynamic-update="false">
<id name="id" type="integer">
<column name="id"/>
<generator class="assigned"/>
</id>
<property name="firstname" type="string">
<column name="firstname" length="98" not-null="true"/>
</property>
<property name="lastname" type="string">
<column name="lastname" length="98"/>
</property>
<set name="bookauthors" inverse="true" cascade="">
<key>
<column name="authorid" not-null="true"/>
</key>
<one-to-many class="com.m2mex2db.data.Bookauthor"/>
</set>
</class>
</hibernate-mapping>