-->
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: Scalar queries problem
PostPosted: Mon Jun 27, 2005 2:50 pm 
Newbie

Joined: Mon Jan 24, 2005 7:12 pm
Posts: 5
The following code comes from the section "9.3.1. Scalar queries" in the Hibernate documentaion

Iterator results = sess.iterate(
"select cat.color, min(cat.birthdate), count(cat) from Cat cat " +
"group by cat.color"
);
while ( results.hasNext() ) {
Object[] row = results.next();
Color type = (Color) row[0];
Date oldest = (Date) row[1];
Integer count = (Integer) row[2];
.....
}


When I put this code into Eclipse, I get the following error for the line:

Object[] row = results.next();

Type mismatch cannot convert Object to Object[]

Can anyone suggest the correct line of code for this statement.

Thanks for your help in advance.

Judy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 27, 2005 3:38 pm 
Newbie

Joined: Mon Jan 24, 2005 7:12 pm
Posts: 5
The answer is:

Object[] row = (Object[]) results.next();

However even when I put in the correct code this still will not work for me.

If anyone has code that's actually worked to find the max value of one column in a table, I would be very appreciative to see it.


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.