[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2304) Wrong type detection for sql type char(x) columns

Julien Kronegg (JIRA) noreply at atlassian.com
Fri Mar 13 10:27:40 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2304?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32648#action_32648 ] 

Julien Kronegg commented on HHH-2304:
-------------------------------------

Hibernate version: 3.3.1.GA
Database: DB2 DSN08015
JDBC driver version : IBM DB2 JDBC Universal Driver Architecture 2.3.63
Hibernate Dialect: DB2390Dialect

I'm having a table with CHAR(8) which is mapped into a java.lang.Character when doing a native query :

    List<Object> x = entityManager.createNativeQuery("select charEightColumn from myTable").getResultList();

Thus, the column value is truncated to 1 character. I expected to have a type mapping to java.lang.String (or at least a char[], but not truncated string on a Character).

I applied Krashan Brahmanjara's patch for org.hibernate.dialect.Dialect (but I did not modify the CustomLoader as proposed above) : 

   registerHibernateType( Types.BIT, Hibernate.BOOLEAN.getName() );
- registerHibernateType( Types.CHAR, Hibernate.CHARACTER.getName() );
+ registerHibernateType( Types.CHAR,1, Hibernate.CHARACTER.getName() );
+ registerHibernateType( Types.CHAR,255, Hibernate.STRING.getName() );
   registerHibernateType( Types.DATE, Hibernate.DATE.getName() );
   registerHibernateType( Types.DOUBLE, Hibernate.DOUBLE.getName() )

The CHAR(8) column is now mapped correctly.

One strange thing is that this issue is very old and nobody seems to care about. Is it really an Hibernate issue, or is it something else (e.g. bad usage) ?

> Wrong type detection for sql type char(x) columns
> -------------------------------------------------
>
>                 Key: HHH-2304
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2304
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.0.ga
>         Environment: Hibernate 3.2.0, Oracle 9.2, Oracle JDBC driver 10.2
>            Reporter: Markus Heiden
>         Attachments: hibernate.zip
>
>
> When executing a sql query which returns columns of sql type char(x), a java.lang.Character is returned. This leads to returning just the first character of the value. In my eyes a String should be returned when the char(x) type has a width > 1. I wasn't able to determine whether this is a jdbc driver issue or a hibernate issue. When using sql type char(x) for columns of entities no such problems occur.
> Test case is attached.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list