-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: invalid field in order by clause ?
PostPosted: Fri Oct 27, 2006 8:18 am 
Newbie

Joined: Fri Oct 27, 2006 8:10 am
Posts: 3
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.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 27, 2006 8:24 am 
Newbie

Joined: Fri Oct 27, 2006 8:10 am
Posts: 3
problem solved. copy and paste error in the hbm from a sample. Time for a bigger coffee.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.