Hibernate没有看到getter方法

时间:2013-05-09 00:00:06

标签: spring hibernate wavemaker

由于某种原因,Hibernate没有在我的一个课程中看到一个Getter,或者至少我认为正在发生这种情况。我的hibernate映射文件或其他XML配置文件中是否存在错误?

我向您展示的代码是由WaveMaker生成的,应该可以正常工作。我试图运行一个简单的HQL查询,但我总是得到以下错误。查询的简单程度或查询的实体并不重要,我总是得到“找不到getter”错误。

我正在使用WaveMaker 6.5,它在安装过程中会下载任何版本的Hibernate和Spring。

这是我得到的错误:

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

以下是我的作者类的代码:

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>
相关问题