I am using Hibernate3 over a Mysql V5 database running under Tomcat V5.
I have two tables, both of which have an attribute (column) with the name “name”. I am driving a native query against the database that joins these two tables and selects both name attributes.
I am using createSQLQuery’s list method (i.e. List result = sess.createSQLQuery(“select ….”).list();).
My select statement looks like this .
select i.id as id , i.name as username, s.name as schoolname from table1 i , table2 s where i.table2id = s.id
I turned on hibername logging and see this :
Code:
Sep.09 11:57:09 http-8080-Processor24 org.hibernate.type.IntegerType - returning '13' as column: id
Sep.09 11:57:09 http-8080-Processor24 org.hibernate.type.StringType - could not read column value from result set: name; Column 'name' not found.
Sep.09 11:57:09 http-8080-Processor24 org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
Sep.09 11:57:09 http-8080-Processor24 org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
Sep.09 11:57:09 http-8080-Processor24 org.hibernate.jdbc.AbstractBatcher - closing statement
Sep.09 11:57:09 http-8080-Processor24 org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
Sep.09 11:57:09 http-8080-Processor24 org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
Sep.09 11:57:09 http-8080-Processor24 org.hibernate.util.JDBCExceptionReporter - could not execute query [select i.id as id , i.name as username, s.name as schoolname from table1 i , table2 s where i.table2id = s.id ]
If I remove the i.name and s.name columns from the select it runs fine on Windows. And like I said in the title, the original query runs fine on Linux.
If you have seen anything like this you insight would be most welcome.