-->
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 and type boxing
PostPosted: Thu Oct 18, 2007 5:19 am 
Newbie

Joined: Thu Oct 18, 2007 5:07 am
Posts: 3
Hi all

I'm building a framework using Struts and Hibernate. I am trying to automate a search form.
Basicly, in my form, the field name is a column name of my persistant object, whereas the value is the criteria value.
Once I submit the form, I build a map, the key is the column name and the value is the value to search for. Then, I build as many Criterion as elements in the map and add them to my Criteria.
Everything works really fine when my search fields are Strings, but whenever it'a another type, I get an exception when executing the Criteria (ClassCast, obviously).

My question is : is there anyway to perform a type boxing when creating the Criteria?
Lets say I want to search by "id", which is long. Expression.eq("id", "305") could internaly convert String "305" into the required Long object.

Since Hibernate doesn't do it, is anyone aware of some solution to help me out?

Thanks in advance


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.