Chinese garbled characters in hql Query

Source: Internet
Author: User

Problem description: If the parameter in the hql statement is Chinese, it is garbled after execution.

Solution: add the following statement to hibernate. cfg. xml:

<Property name = "hibernate. query. factory_class "> </P> <p> Org. hibernate. hql. classic. classicquerytranslatorfactory </P> <p> </property> <br/>

In this way, the input parameters are garbled.

This solves the problem of Chinese garbled characters in the hql statement. However, if you use the hibernate update method, an error is returned.

Cause: the property of hibernate. query. factory_class is the factory class for configuring the Hibernate query translator. The above configuration is hibernate2.x. hibernate does not support the updated hql at 2.x. In hibernate3.x, the default translator is 3, but if the hql statement contains Chinese characters, it will be garbled.

Solution: when writing hql, use the setxxx method of query.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.