-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: mysql enum String index out of range createSQLQuery
PostPosted: Tue Aug 10, 2010 5:42 am 
Newbie

Joined: Thu Oct 02, 2008 9:15 am
Posts: 3
I think I found a bug in Hibernate in the current release 3.5.3 used with mysql. I use mysql and a column is of type enum. When the enum column has a valid alternative of a zero-length string I will get an exception:
could not read column value from result set String index out of range: 0

Code:
mysql> desc test;
+-------+-------------------
| Field   | Type
+-------+-------------------
| id       | int(11)
| a        | enum('a','b,'c,'')


Session currentSession = HU.getSessionFactory().getCurrentSession();
String sql=" select * from test";
List result = currentSession.createSQLQuery(sql).list();
Iterator it = result.iterator();


Workaround: Use this sql instead to cast the enum to a char:
Code:
select id, cast(a as char) from test


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.