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

Krashan Brahmanjara (JIRA) noreply at atlassian.com
Mon Mar 3 07:48:33 EST 2008


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

Krashan Brahmanjara commented on HHH-2304:
------------------------------------------

The problem sill exist in 3.2.6a with IBM informix jdbc driver.

Somewhere in   CustomLoader.getHibernateType( or factory.getDialect().getHibernateTypeName
char(?) is mapped to Character for columnType==1.

Another problem is CustomLoader.getHibernateType which incorrectly detect length of char fields
my patch detect it better but it is not solution of bad mapping of Character type fields.

public Type getHibernateType(int columnPos) throws SQLException {
//char length or precision
int precision = resultSetMetaData.getPrecision( columnPos );
+ int length = precision;
+ if (columnType==1 && precision==0){
+     length = resultSetMetaData.getColumnDisplaySize(columnPos);
+ }
return TypeFactory.heuristicType(
  factory.getDialect().getHibernateTypeName(
   columnType,
- precision,
+ length,
   precision,
scale
) 
(...)

> Wrong type detection for sql type char(x) columns
> -------------------------------------------------
>
>                 Key: HHH-2304
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2304
>             Project: Hibernate3
>          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