This is my code:
Code:
String sql = "SELECT {m}.* FROM MSG_OUT {m}";
List msgout = session.createSQLQuery(sql, "m", MsgOut.class).list();
I am using postgresql 7.3.6 and hibernate 2.1.4 (and the nightly tar on June 03) and it appears I am getting this same problem. I have successfully changed my query to HQL using session.find() to get it to work, but if I use native SQL it gives me the following error. Same problem if I used named queries (I'm assuming it uses the same calls). Please help.
Code:
DEBUG 11:35:42 net.sf.hibernate.SQL [main] SELECT m.* FROM MSG_OUT m
DEBUG 11:35:42 net.sf.hibernate.impl.BatcherImpl [main] preparing statement
DEBUG 11:35:58 net.sf.hibernate.loader.Loader [main] processing result set
DEBUG 11:35:58 net.sf.hibernate.util.JDBCExceptionReporter [main] SQL Exception
The column name msg_id0_ not found.
at org.postgresql.jdbc1.AbstractJdbc1ResultSet.findColumn(AbstractJdbc1ResultSet.java:528)
at org.postgresql.jdbc1.AbstractJdbc1ResultSet.getInt(AbstractJdbc1ResultSet.java:358)
at net.sf.hibernate.type.IntegerType.get(IntegerType.java:18)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
at net.sf.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:352)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:203)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3802)
at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
at hibernate.Tester.<init>(Unknown Source)
at hibernate.Tester.main(Unknown Source)
WARN 11:35:58 net.sf.hibernate.util.JDBCExceptionReporter [main] SQL Error: 0, SQLState: null
ERROR 11:35:58 net.sf.hibernate.util.JDBCExceptionReporter [main] The column name msg_id0_ not found.
DEBUG 11:35:58 net.sf.hibernate.impl.BatcherImpl [main] done closing: 0 open PreparedStatements, 0 open ResultSets
DEBUG 11:35:58 net.sf.hibernate.impl.BatcherImpl [main] closing statement