---
title: "mysql+hibernate写HQL语句时报错 unknown column ‘XXX’ in where clause"
author: "东流水"
date: "2011-01-24T23:04:46Z"
tags: []
categories: ["企业架构"]
slug: "mysql-hibernate-hql-unknown-column-xxx-in-where-clause"
draft: false
lastmod: "2011-01-24T23:04:46Z"
id: 894170
url: "https://992012.iteye.com/blog/894170"
---

单从字面上是列名不存在，但是实际上却是因为少写了单引号而引起的， 例如：（其中id是用uuid生成，对应是string类型) List list2 =session.createQuery("from User where id= "+"ff8080812d9f1104012d9f11053a0001").list(); 则会报一下错误 Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'ff8080812d9f1104012d9f11053a0001' in 'where clause' 修改HQL如下 List list2 =session.createQuery("from User where id= '"+"ff8080812d9f1104012d9f11053a0001"+"'").list(); 成功运行