-->
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: How to obtain field types programmatically?
PostPosted: Sun Aug 01, 2010 4:11 pm 
Newbie

Joined: Sat Mar 20, 2010 7:26 am
Posts: 6
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


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.