-->
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: Parameter binding automatic conversion
PostPosted: Fri May 15, 2009 5:41 am 
Newbie

Joined: Mon Aug 22, 2005 2:34 pm
Posts: 4
Hi,

It's possible to apply some automatic conversion logic when binding parameters?

For example if I apply a Integer parameter to Long column, or String to Integer, with the setParameter(), can Hibernate automatically convert it to the correct type, or can I inject some conversion logic?
Because I get classcastsexception like that:
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long
at org.hibernate.type.LongType.set(LongType.java:42)


I know how to convert the values, but the problem is that I don't know to what type I've to convert. I've looked at setParameter code and I've seen that when you set the parameter Hibernate knows the real type of the parameter and stores it in ParametersMetadata, but the problem is that I've seen any exposed method to retrieve that information.

Something like, what is the type of parameter named 'xxxx'?

Also I've seen that LongType and similar, have a fromStrimg method? But it doesn't seem to be used, is it?

Cheers,


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.