-->
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: Newbie query question
PostPosted: Thu Jan 19, 2012 1:40 pm 
Newbie

Joined: Thu Jan 19, 2012 1:21 pm
Posts: 12
Using Hibernate with NetBeans 6.9.1

I'm new to Hibernate and have a query question.
I have a table eventTable with multiple entries for a given userId.
Among the table columns are an accessDate field.
I need a query that will allow me to fetch back the last access by accessDate for all userIds.

How would I go about that?
What would the call to session.createQuery() look like?

Also, I would appreciate links to any sites that have good tutorials on hibernate and things like query construction.

Thanks.


Top
 Profile  
 
 Post subject: Re: Newbie query question
PostPosted: Mon Jan 23, 2012 10:10 pm 
Newbie

Joined: Thu Jan 19, 2012 1:21 pm
Posts: 12
Maybe I should have been a bit more detailed in my question???

My event table is named tbEventTrxn table has the following columns:
dcLatitude, dcLongitude, dtTrxnTime, (along with several others).

When I attempt to fetch the values from within NetBeans, using their HQL query editor, I enter the following command:
select trxn.dcLatitude, trxn.dcLongitude, max(trxn.dtTrxnTime) from TbEventTrxn trxn

and I get the following error, which I do not understand:
Code:
org.hibernate.exception.SQLGrammarException: could not execute query
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.loader.Loader.doList(Loader.java:2223)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
   at org.hibernate.loader.Loader.list(Loader.java:2099)
   at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:912)
   at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Column 'ROVRDEV.dbo.tbEventTrxn.dcLatitude' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
   at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:213)
   at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1493)
   at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:388)
   at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:338)
   at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5574)
   at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1734)
   at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179)
   at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154)
   at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:281)
   at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
   at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
   at org.hibernate.loader.Loader.doQuery(Loader.java:674)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
   at org.hibernate.loader.Loader.doList(Loader.java:2220)
   ... 8 more


In particular, I do not understand why I get this error:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Column 'ROVRDEV.dbo.tbEventTrxn.dcLatitude' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

Can't anyone point me in the right direction???


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.