Hello I've this simple query that I've to do in native SQL:
Code:
SQLQuery query = sess.createSQLQuery("SELECT * from " + table + " WHERE " + filter + " LIKE '" + search + "%'");
System.out.println(query.toString());
List<Object[]> result = query.list();
so there is no mapping. It works most of the times. The problem is when I use a certain table in a mySQL db with this schema:
Code:
CREATE TABLE `nazioni` (
`nazid` int(11) NOT NULL AUTO_INCREMENT,
`nazsigla` varchar(8) NOT NULL DEFAULT '',
`naznome` varchar(50) NOT NULL DEFAULT '',
`nazcontinente` varchar(50) DEFAULT NULL,
`naziso` varchar(4) DEFAULT NULL,
`nazeuro` char(1) DEFAULT NULL,
`nazvalucod` varchar(10) DEFAULT NULL,
`nazvaluid` int(11) DEFAULT NULL,
`nazcod` varchar(4) DEFAULT NULL,
`nazcbe` varchar(4) DEFAULT NULL,
`nazcitt` varchar(50) DEFAULT NULL,
`nazstato` char(1) DEFAULT NULL,
`naznomeiso` varchar(50) DEFAULT '',
`nazisoex` varchar(10) DEFAULT '',
`nazlinguaid` int(11) DEFAULT '-1',
`nazlingua` varchar(50) DEFAULT '',
PRIMARY KEY (`nazid`),
UNIQUE KEY `naznome` (`naznome`),
KEY `nazsigla` (`nazsigla`)
) ENGINE=MyISAM AUTO_INCREMENT=244 DEFAULT CHARSET=latin1
and I shouldn't modify this. The problem is with the field
Code:
nazeuro
that sometimes is NULL. It causes this exception:
Code:
4-feb-2010 12.53.42 org.hibernate.type.NullableType nullSafeGet
INFO: could not read column value from result set: nazeuro; String index out of range: 0
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:686)
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:606)
at org.hibernate.loader.Loader.doQuery(Loader.java:701)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
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 Views.Components.QuickLookup$updater.run(QuickLookup.java:91)
How can I solve this, possibly without touching the DB