-->
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.  [ 6 posts ] 
Author Message
 Post subject: from hib3.2.5GA TO hib3.2.6GA
PostPosted: Thu Jun 05, 2008 9:50 am 
Beginner
Beginner

Joined: Tue Aug 29, 2006 8:08 am
Posts: 34
Using Java 1.5 and Hibernate versions referred in subject,
just a simple line like

int count = (Integer) session.createQuery("select count(*) from mytable").uniqueResult()


causes a ClassCastException in Hib3.2.6GA BUT IT DOES NOT in Hib3.2.5GA

¿!?¿!?¿!?¿! A BUG ???


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 05, 2008 11:35 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Here's an idea.

Just cast it into an object, and then do a getClass() call on the object that is returned. Then post back and tell us what the object type is! That should answer pretty much all the questions, and help out everyone else that runs into a similar problem.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Done
PostPosted: Thu Jun 05, 2008 12:07 pm 
Beginner
Beginner

Joined: Tue Aug 29, 2006 8:08 am
Posts: 34
Relatively interesting your proposal, and very interesting results :::

----------
final Object count = session
.createQuery("select count(*) from ModuleJar").uniqueResult();
System.err.println("result:::" + count.getClass());
-----------

and guess what? Integer results ......reaaaaaally funny.

Any way it's obviously something i've worked around with some code like this:::

final Object count = session
.createQuery("select count(*) from ModuleJar").uniqueResult();
int num = Integer.parseInt(""+count)

Not elegant, rather stupid, but that's it. In former version it worked as expected and as I upgraded this silly matter arose.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 05, 2008 2:37 pm 
Regular
Regular

Joined: Mon Apr 19, 2004 6:54 pm
Posts: 79
I think 'select count(*) ..' returns a long


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 05, 2008 5:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The above is correct - there was a change in the return type for a Count.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 06, 2008 11:51 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
I love it when a plan comes together. :)

Troubleshooting can be fun.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.