Pergunta

For some reason Hibernate is not seeing a Getter in one of my classes, or at least that's what I think is happening. Is there something I have set wrong in my hibernate mapping file or a different XML configuration file?

The code I am showing you is generated by WaveMaker and is supposed to work. I am trying to run a simple HQL query but I always get the following error. It doesn't matter how simple the query is or on what entities I query, I always get the "Could not find a getter" error.

I am using WaveMaker 6.5 with whatever version of Hibernate and Spring it downloads during installation.

Here is the error I get:

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

Here is the code of my Author class:

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;
}

}

and here is my Hibernate mapping file:

<!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>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top