[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2304) Wrong type detection for sql type char(x) columns
Bart Vanhaute (JIRA)
noreply at atlassian.com
Thu Mar 12 08:26:43 EDT 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2304?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32635#action_32635 ]
Bart Vanhaute commented on HHH-2304:
------------------------------------
(Using mysql 5.0) when the data in the column is the empty string, I get:
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:558)
at org.hibernate.type.CharacterType.get(CharacterType.java:29)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:189)
at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.extract(CustomLoader.java:474)
at org.hibernate.loader.custom.CustomLoader$ResultRowProcessor.buildResultRow(CustomLoader.java:420)
at org.hibernate.loader.custom.CustomLoader.getResultColumnOrRow(CustomLoader.java:317)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:614)
at org.hibernate.loader.Loader.doQuery(Loader.java:709)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:244)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2112)
at org.hibernate.loader.Loader.list(Loader.java:2107)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:66)
I have found the following workaround for native queries:
instead of
select val from table
do
select cast(val as char) from table
> 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