-->
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.  [ 2 posts ] 
Author Message
 Post subject: Sybase Dialect problem for smallint
PostPosted: Thu Mar 02, 2006 6:57 pm 
Newbie

Joined: Thu Mar 02, 2006 6:50 pm
Posts: 1
hi ,
am using the following dialect "org.hibernate.dialect.SybaseDialect",
There is a field in the database which is of type smallint.When i execute a query it returns the following exception

eg ..input = 1
Implicit conversion from datatype 'VARCHAR' to 'SMALLINT' is not allowed. Use the CONVERT function to run this query.

However the same query with the same input works on an MSSQL database with the corresponding dialect.

Does this mean that to handle this situation i need to code seperatley for sybase using COVERT in my sql query???


Any help is highly appreciated.

Thanks
BT


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 9:09 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
If your DBMS doesn't handle varchar to smallint, then you'll have to handle it for it. You could define a UserType for it, but using Short.parseShort(String) is probably easier. Your dialect implicitly maps shorts to smallints, so using Short.parseShort(String) has the advantage that if the string would have caused the DB to throw an exception, you'll now get an exception earlier. Failfast code for free!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.