-->
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: Informix casting incorrectly?
PostPosted: Tue Oct 14, 2008 6:39 am 
Newbie

Joined: Fri Oct 10, 2008 11:17 am
Posts: 9
When I run an Informix SQL query through Hibernate, it seems to be mis-casting all char(n) fields as Character and not String. How can I tell Hibernate to cast all fields defined as char(n) as a String?

This isn't particularly helpful. So the string "Hello World" if stored in a char(20) fields becomes "H".

Yes, I know I can correct this by adding scalars to the SQLQuery, but when you've done it to 200 queries already, and I would like to be able to execute user SQLs (where the type is not necessarily known), it gets very annoying!


I think I can actually see the error in the dialect code!

registerColumnType(Types.CHAR, "char($l)");

Should be something like

registerColumnType(Types.VARCHAR, "char($l)");
registerColumnType(Types.CHAR, "char(1)");

(not sure how precedence works here).

Alternatively, how do I get a raw, simple JDBC connection out of hibernate? We're using JPA persistence coupled to hibernate - is there any way to get a simple JDBC connection from it to work around Hibernate bugs?


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.