Hibernate异常:org.hibernate.exception.SQLGrammarException:无法执行查询

时间:2009-07-13 10:41:32

标签: hibernate exception

我收到以下错误。不知道为什么会这样。我也检查了DB它看起来很好。

Hibernate: select customer0_.CustomerId as CustomerId0_, customer0_.CustomerAlias as Customer2_0_ from FF_REFERENCE.dbo.Customer customer0_ where customer0_.CustomerId=?

org.hibernate.exception.SQLGrammarException: could not execute query
   Caused by: java.sql.SQLException: [Macromedia][Sybase JDBC Driver]**Invalid column name: CustomerId0_**

我的pojo是:

public class Customer implements java.io.Serializable {

// Fields

private String customerId;
private String customerAlias;

}

hbm是:

<hibernate-mapping>
<class name="com.pojo.reference.Customer" table="Customer" >
    <id name="customerId" column ="CustomerId" length="18" />
        <property name="customerAlias" type="java.lang.String">
            <column name="CustomerAlias" length="18" />
        </property>

我使用的查询是:

public List findByProperty(String propertyName, Object value,String region) {
    try {
        String queryString = "from Customer as model where model."
                + propertyName + "= ?";
        Query queryObject = getSession().createQuery(queryString);
        queryObject.setParameter(0, value);
        return queryObject.list();
    } catch (RuntimeException re) {
            }
}

我打电话使用:

custDao.findByProperty("customerId", custName, region);

1 个答案:

答案 0 :(得分:1)

得到了答案。部署的战争从错误的地方夺走......