Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Aggregate function in HQL

 
Parameswaran Thangavel
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
i am using the below query in my program..



here when i am retrieving the value using query.list, it returns the object, the problem is the object is not of type TwaevntRsrcRt as expected.

and also i tried to create a new class having the values listed in select list, still thats too failed



Throwing the error Class Not Found Exception.... i placed the ResourceDetails class in class path. is some where i need to mention the file name..

any idea wheres the problem....
Thanx in advance
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aggregate queries always return a list of Object[], in your case:

See 3.4.1.2. Scalar results.
 
Parameswaran Thangavel
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Reynders,
Thanx for ur reply,
i am facing certain problems listed below...

1) the query is not returning the list of array objects its retuning just list of objects
2) There is no function available named getResultList() for a query object.

Can you help me out???

ThanX
Param.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For Hibernate 2 please refer to 9.3.1. Scalar queries.
 
Parameswaran Thangavel
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i went through the 9.3.1 section which i listed below.



in the example given above the "results.next()" will always return the object not array of objects, but how they given the example in which results.next returns the array of object, is there any version problem, i am using the Hibernate 2.1.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the Session interface you will notice that the deprecated iterate method returns a java.util.Iterator. So that interface is the "limitation"; the iterator's next() method returns an Object. So that code snippet is just sloppy. The line probably should read:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic