-->
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.  [ 1 post ] 
Author Message
 Post subject: Criteria Like Search For a Number
PostPosted: Tue Dec 28, 2004 7:57 pm 
Newbie

Joined: Tue Dec 28, 2004 7:41 pm
Posts: 7
I'm trying to do a like search for a property that is a Long and I can't seem to figure out what needs to be done. Even after stripping all the properties other than the primary key the following results in a ClassCastException

Criteria criteria = session.createCriteria(SomeClass.class);
criteria.setMaxResults(MAX_RESULTS);
criteria.add(Expression.like("someId", "%234140"));


I'm able to sucessfully query fine with Expression.eq but I would like to do a like query.

-Eric

Hibernate version:
2.1

Name and version of the database you are using:
Oracle 9i


Mapping documents:

<id name="someId"
type="java.lang.Long"
column="SOME_ID"
>
<generator class="assigned" />
</id>


Full stack trace of any exception that occurs:

java.lang.ClassCastException
at net.sf.hibernate.type.LongType.set(LongType.java:32)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)
at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:749)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:788)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:265)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:118)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3613)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.