[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-4723) Column in SQL query is returned as java.lang.Character

Strong Liu (JIRA) noreply at atlassian.com
Thu Oct 13 10:10:22 EDT 2011


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4723?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Strong Liu resolved HHH-4723.
-----------------------------

    Resolution: Duplicate

duplicated by HHH-2304

> Column in SQL query is returned as java.lang.Character
> ------------------------------------------------------
>
>                 Key: HHH-4723
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4723
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-sql
>    Affects Versions: 3.3.1
>            Reporter: Nick de Graeve
>
> When I run this code sample:
> {{List data = session.createSQLQuery("select e.country_iso_code from agent.tbd3_Entry e where e.country_iso_code = 'BE'").list();}}
> {{Object row = data.get(0);}}
> {{System.out.print(row + ": " + row.getClass());}}
> I get this result:
> {{B: class java.lang.Character}}
> I expect to get a {{java.lang.String}} containing "BE", not just the 1st Character.
> The column country_is_code of table tbd3_entry is defined in Oracle as {{COUNTRY_ISO_CODE    CHAR(2 BYTE)}}
> When I add a scalar with correct type I do get what I need:
> {{List data = session.createSQLQuery("select e.country_iso_code countryIsoCode from agent.tbd3_Entry e where e.country_iso_code = 'BE'").addScalar("countryIsoCode", Hibernate.STRING).list();}}
> {{Object row = data.get(0);}}
> {{System.out.print(row + ": " + row.getClass());}}
> results in 
> {{BE: class java.lang.String}}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list