I've created a very basic hibernate query
Session session = HibernateSessionFactory.getInstance().getCurrentSession();
Transaction tx = session.beginTransaction();
List results = session.createQuery("from Blog as bl where bl.link=?").setString(0, uri).list();
This is expected to return a list of Blog objects with contains a one-to-many mapping of BlogPost objects.
The Blog table has no datetime fields, the BlogPost table has a single datetime field called publishedDate
Statements generated:
Hibernate: select blog0_.blogId as blogId3_, blog0_.title as title3_, blog0_.link as link3_, blog0_.feed as feed3_, blog0_.language as language3_ from Blog blog0_ where blog0_.link=?
Hibernate: select entries0_.blogId as blogId1_, entries0_.blogPostId as blogPostId1_, entries0_.blogPostId as blogPostId4_0_, entries0_.title as title4_0_, entries0_.link as link4_0_, entries0_.technotags as technotags4_0_, entries0_.metawords as metawords4_0_, entries0_.publishedDate as publishe6_4_0_, entries0_.blogId as blogId4_0_ from BlogPost entries0_ where entries0_.blogId=? order by time asc
Error:
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.sql.SQLException: Unknown column 'time' in 'order clause'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1600)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1695)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3004)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1128)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1222)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1668)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1918)
... 36 more
I have no idea why it thinks there is a field called "time" for which it can execute an order by...
any help would be greatly appreciated.
Nick.
|