This is probably easily achieved, however, I could not find an answer just by googling or searching the forums.
The task is to obtain the type of a specific field mapped to the DB in order to cast a query value in a criteria query to the correct type.
I.e. we have the following information:
Class clazz, String fieldNameOfClazz, String fieldValueOfFieldNameOfClazz
Now I'd like construct a criteria with restrictions using the above information, e.g. something like:
Code:
Criteria c = session.createCriteria(clazz);
if(c.getTypeOfField(fieldNameOfClazz) =="java.lang.Float"){
c.add(Restriction.lt(fieldNameOfClazz, Float.parseFloat(fieldValueOfFieldNameOfClazz));
}
How can this be done?
Thanks
fatzopilot