I'm using Hibernate 2.1.2, mysql 4.0.14, old mysql driver (org.gjt.mm.mysql..)
Code:
SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session sess = sf.openSession();
try {
tx = sess.beginTransaction();
int bigcount = ( (Integer) sess.iterate("select count(*) from problems").next() ).intValue();
} finally {
sess.close();
I continually get hsql translation errors:
Code:
DEBUG net.sf.hibernate.hql.QueryTranslator - HQL: select count(*) from problems
SQL: select count(*) as x0_0_ from
DEBUG net.sf.hibernate.hql.QueryTranslator - SQL: select count(*) as x0_0_ from
about to open: 0 open PreparedStatements, 0 open ResultSets
DEBUG net.sf.hibernate.impl.BatcherImpl - about to open: 0 open PreparedStatements, 0 open ResultSets
select count(*) as x0_0_ from
DEBUG net.sf.hibernate.SQL - select count(*) as x0_0_ from
preparing statement
DEBUG net.sf.hibernate.impl.BatcherImpl - preparing statement
SQL Exception
java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax. Check the manual that corresponds to your My
SQL server version for the right syntax to use near '' at line 1
at org.gjt.mm.mysql.MysqlIO.sendCommand(Unknown Source)
at org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(Unknown Source)
at org.gjt.mm.mysql.Connection.execSQL(Unknown Source)
at org.gjt.mm.mysql.PreparedStatement.executeQuery(Unknown Source)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:795)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:950)
at net.sf.hibernate.loader.Loader.list(Loader.java:941)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1483)
I've tried the query numerous ways, but this is the recommended way in the FAQ, so this should at least work. Anyone know what the problem is here?
Other select queries into this db & table work fine, just not the count.