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

Nick de Graeve (JIRA) noreply at atlassian.com
Mon Dec 21 04:05:30 EST 2009


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.
-
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