2009-07-13 71 views
0

我收到以下錯誤。不知道爲什麼會發生。我也檢查了DB看起來不錯。休眠例外:org.hibernate.exception.SQLGrammarException:無法執行查詢

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

得到了答案。已部署的戰爭正在採取HBM從錯誤的地方...

+3

嗨。當你說從錯誤的地方採取HBM。你能詳細說明嗎?因爲我認爲我可能有同樣的問題 – 2011-01-12 21:35:40

相關問題