RuntimeException:org.hibernate.exception.SQLGrammarException:无法执行查询

时间:2016-10-14 06:53:58

标签: java mysql sql hibernate

我正在使用另一个表连接从名为PurchaseDetailContributor的表中检索记录。但是我收到查询错误。

下面是我的DAOHibernate.java类里面的一个方法。

softId_suggest

我的错误是在联接查询中。

//错误信息

source: function (query, process) {
                    return $.get('/ajax/customtags/gettags', { search: query, userId: 1 },
                        function (data) {});
                },

2 个答案:

答案 0 :(得分:1)

你的sql中没有空格

String sql = "select * from purchase_detail_contributor"
         + "inner join purchasedetail on (purchase_detail_contributor.purchase_detail_id = purchasedetail.purchasedetailid)"
         + "inner join purchase on (purchasedetail.purchasefk = purchase.purchaseid)" 
         + "inner join user on (user.userid = purchase.userid)"
         + "where user.customer_no = :customer_no";

所以sql是

select * from purchase_detail_contributorinner join purchasedetail...

这绝对是语法错误

答案 1 :(得分:1)

您发布了正确的代码吗?

错误显示

11:13:01,074 ERROR [JDBCExceptionReporter:234] Column 'is_approved' not found.