-->
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: criteria vs hql
PostPosted: Wed Nov 19, 2003 6:43 am 
Newbie

Joined: Thu Oct 23, 2003 6:12 am
Posts: 18
Why is it when I use:

Code:
Long oid = new Long(42);
if ((temp = HibSes.curSes().createCriteria(foo.class).add(Expression.eq("id",oid)).list()).size() == 1)


I get a ClassCastException, and

Code:
if ((temp = HibSes.curSes().find("from foo bar where bar.id = ? ", oid, Hibernate.LONG)).size() == 1)

works fine,

I love the criteria API (still some non declarative things in there)
and want to use it everywhere I can.

All I want is to load an Object with an OID,
(I don't know if oid represents a valid objectid)

(I've read somewhere that using load() for this purpose and catching the exception is not elegant)

Bz


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 7:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Are you sure that the id property is mapped as Hibernate type "long"?


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.