简体   繁体   English

SQL异常:where子句中的未知列

[英]SQL Exception: Unknown column in where clause

I am using Hibernate3 with spring application. 我在Spring应用程序中使用Hibernate3。 I introduced a column in my existing table with many to one relationship with the addition in the .hbm file as mentioned below: 我在现有表中引入了一个列,该列与.hbm文件中的添加具有多对一关系,如下所述:

<many-to-one name="qualityStatus" column="quality_status" 
    class="model.PurchaseStatus" lazy="false" fetch="join"/>

The corresponding object to this hbm has a property of type 'PurchaseStatus' and field name as 'qualityStatus'. 该hbm的对应对象的属性类型为'PurchaseStatus',字段名称为'qualityStatus'。

Now when i try fetching the data from the table representing the above object with the query: 现在,当我尝试通过查询从代表上述对象的表中获取数据时:

List<Long> dnIds = session.createQuery("select dnItem.dnId from DeliveryNoteItem dnItem where dnItem.qualityStatus!=? and dnItem.qualityStatus!=? and dnItem.qualityStatus!=?")
       .setInteger(0,1)
       .setInteger(1,5)
       .setInteger(2,7)
       .list();

i get an error saying as 'java.sql.Exception: Unknown column 'deliveryno0_.quality_status' in 'where clause' I get this error when deployed on test server but when i check the same thing on my local server i works fine as well when i just run this query directly on the database on the test server it returns me result. 我收到一个错误消息,提示为'java.sql.Exception: Unknown column 'deliveryno0_.quality_status' in 'where clause'当部署在测试服务器上时出现此错误,但是当我在本地服务器上检查相同的内容时,我也能正常工作当我直接在测试服务器上的数据库上直接运行此查询时,它将返回我结果。 So it confirms that the database on the test server is alright. 因此,它确认测试服务器上的数据库还可以。 It is only when it executes through the application on the test server i am getting this error. 仅当它通过测试服务器上的应用程序执行时,我才收到此错误。

Can anybody let me know what can be the reason or how do i debug this out. 任何人都可以让我知道是什么原因或如何调试此原因。 Thanks in advance. 提前致谢。 Looking forward for replies. 期待得到答复。

If you really have a quality_status column in your database, then you should make sure you have the most recent version of your application deployed on the test server, and make sure that the connection url of hibernate really points to the test database. 如果数据库中确实有quality_status列,则应确保在测试服务器上部署了应用程序的最新版本,并确保休眠的连接URL确实指向了测试数据库。

This is not a hibernate problem, not a programming one. 这不是休眠问题,也不是编程问题。 It is environmental - check your configurations and redeploy. 这是环境问题-检查您的配置并重新部署。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM