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
|