Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.1
Name and version of the database you are using:
Oracle 10g
When I run this native SQL query in oracle through Hibernate "select 'hello' from dual".
It returns the Character "h" in Java. The reason is that in the dialect, it maps the type "Char" in the DB to Character in Java. This doesnt seem like th ebest choice since Char in Oracle can be more than size 1... In this case size 5. The same behavior occurs with native unmapped sql to a char column in the DB. If I do this, it fixes it:
Code:
Dialect dialect = ((SessionFactoryImpl)this.session.getSessionFactory()).getDialect();
if (dialect instanceof Oracle9Dialect) {
//there is a native sql problem where "char" database types get truncated since
//read as char, so we will read them as String
FastReflectionUtils.callMethod(Dialect.class, dialect, "registerHibernateType",
new Class[]{int.class, String.class}, new Object[]{Types.CHAR, Hibernate.STRING.getName()}, false, true);
}
Maybe this change should go into the Hibernate codebase in the Oracle9i dialect where it registers JDBC types with hibernate types???
Thanks,
Chris