Hi all
Hibernate version: 3
Mapping documents:
<hibernate-configuration>
<session-factory>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@192.168.1.5:1521:citytran</property>
<property name="hibernate.connection.username">dbo</property>
<property name="hibernate.connection.password">111</property>
<property name="c3p0.max_size">2</property>
<property name="c3p0.min_size">0</property>
<property name="c3p0.timeout">10</property>
<property name="c3p0.max_statements">50</property>
<property name="c3p0.idle_test_period">3000</property>
<property name="c3p0.acquireRetryAttempts">1</property>
<property name="jdbc.batch_size">0</property>
<property name="jdbc.batch_versioned_data">false</property>
<property name="jdbc.use_streams_for_binary">true</property>
<property name="max_fetch_depth">1</property>
<mapping resource="User.hbm.xml"/>
.....
</session-factory>
</hibernate-configuration>
And test object mapping
<hibernate-mapping>
<class name="User" table="USERS" dynamic-update="true" >
<id name="id" unsaved-value="null" type="long" column="userid" >
<generator class="sequence">
<param name="sequence">SQ_USERS</param>
</generator>
</id>
<property name="username" type="string" column="USERRESUME" />
...
</class>
</hibernate-mapping>
Name and version of the database you are using:
Oracle 9.2
CREATE TABLE USERS (
USERID NUMBER (10) NOT NULL,
USERNAME VARCHAR2 (50) NOT NULL,
.....
And the problem:
If i try to get list of users with condition like this
Code:
String username = "Гр..ор..";
List list = ses.createQuery("from User u where u.username = '" + username + "'").list();
i get the following log:
The generated SQL (show_sql=true):....
14:42:04,850 WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/ScarPro/libs/Hibernate3/ehcache-1.1.jar!/ehcache-failsafe.xml
14:42:05,615 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
14:42:05,615 INFO SessionFactoryImpl:379 - Checking 0 named queries
Hibernate: select user0_.userid as userid, user0_.USERRESUME as USERRESUME0_ from DBO.USERS user0_ where user0_.USERRESUME='??????'questions signs instead user name.
And if i do the same without hibernate:
Code:
Class.forName("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.5:1521:citytran", "dbo", "111");
Statement statement = con.createStatement();
ResultSet resultSet = statement.executeQuery("select * from USERS where USERNAME='Гр..ор..'");
if(resultSet.next()) {
System.out.println(resultSet.getString("username"));
}
it works.
Why hibernate convert string encoding?
Thanks.