简体   繁体   中英

SQL Exception: Unknown column in where clause

I am using Hibernate3 with spring application. I introduced a column in my existing table with many to one relationship with the addition in the .hbm file as mentioned below:

<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'.

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. 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.

This is not a hibernate problem, not a programming one. It is environmental - check your configurations and redeploy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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