---
title: "Hibernate 中拼接 HQL 乱码"
author: "as619864232"
date: "2012-10-19T20:06:52Z"
tags: ["hql", "乱码", "拼接"]
categories: ["企业架构"]
slug: "hibernate-hql"
draft: false
lastmod: "2012-10-19T20:09:50Z"
id: 1701880
url: "https://ears.iteye.com/blog/1701880"
---

hql＝" ... like '%中文%'";   
getSession().createQuery(hql);   
query.setFirstResult(firstResult);   
query.setMaxResults(perPageCount);   
query.list();   
后台打印出转化后的语句 中 变成了like '%??%'"; 

 

hibernate 配置中添加下列属性：

 

```
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
```