Hibernate selects nothing

I have MySQL InnoDB table utf-8 encoded. This table has only id and name field. Names are in russian language and 1 name in English for testing purpose. English name selects ok but when trying to select with russian name it returns empty list. I tried to build queries both with Criterion and HQL.

getHibernateTemplate().find("from FirstName where name='free' ");
getHibernateTemplate().find("from FirstName where name='ИННА' ");

Here is connection string - ?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8

i'm using hibernate 3.2.7.ga and spring 2.5.6.SEC03

Here is hibernate log:

Hibernate: /* from FirstName where name='ИННА'  */ select firstname0_.`id` as id1_24_, firstname0_.`name` as name2_24_ from `first_name` firstname0_ where firstname0_.`name`='ИННА' limit ?

Answers


Thanks to all, i have found an answer.

The problem was in connection string. I did refactor and moved connection string to the properties file instead of xml with spring-bean. But i did not changed "&" entity to the "&". Successfull connection string is in properties file

jdbc:mysql://${host}:${port}/${database}?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8

XML file changes & entities to the correct, but properties format don't do this.


Criteria coCriteria = Session.createCriteria(coClass).add(Restrictions.eq(strColumnName, strColumnValue));
list = coCriteria.list();

Did you try with this hibernate criteria. Where "Session" will the session object of hibernate generated session. 1)coClass = "pojo class name" 2)strColumnName = "pojo class field name" in your case it will be "name" i guess 3)strColumnValue = in your case it will be "ИННА"


Did you try changing the character encoding at database level? According to MySQL documentation, Cyrillic characters are supported with "cp1251"

You may take a look at this link as well


Need Your Help

How can shutdown the PC with Assembly 16 bits in boot mode?

assembly operating-system boot shutdown

I wrote a small bootloader that i write in a Diskette, the bootloader is working fine, i write a function to reboot the PC, but i can't shutdown the PC, i try a lot but i've just got an infinite beep

rails image_submit_tag with cucumber/webrat

ruby-on-rails rspec cucumber webrat

I've the following search form with image_submit_tag instead of submit_tag.