-->
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.  [ 7 posts ] 
Author Message
 Post subject: Sybase Convert Exceptions using Hibernate
PostPosted: Thu Dec 22, 2005 6:01 pm 
Newbie

Joined: Thu Dec 22, 2005 5:53 pm
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hi.
I am trying to use Hibernates SybaseDialect for Sybase. My query is a simple select query which takes a parameter of int. On Execution i get an error "Implicit conversion from datatype 'VARCHAR' to 'SMALLINT' is not allowed. Use the CONVERT function to run this query."
The same query works fine with MS Sql Server.
DO i need to explicitly use the CONVERT function just for Sybase in my HQL.???
I am using Hibernate3.0 and net.sf.hibernate.SybaseDialect.
Any help in this would be highly appreciable.

Thanks
Binny


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 11:43 am 
Newbie

Joined: Thu Dec 22, 2005 5:53 pm
Posts: 4
Can anyone pls help me out in this


Top
 Profile  
 
 Post subject: Re: Sybase Convert Exceptions using Hibernate
PostPosted: Tue Dec 27, 2005 1:41 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
binnythomas01 wrote:
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hi.
I am trying to use Hibernates SybaseDialect for Sybase. My query is a simple select query which takes a parameter of int. On Execution i get an error "Implicit conversion from datatype 'VARCHAR' to 'SMALLINT' is not allowed. Use the CONVERT function to run this query."
The same query works fine with MS Sql Server.
DO i need to explicitly use the CONVERT function just for Sybase in my HQL.???
I am using Hibernate3.0 and net.sf.hibernate.SybaseDialect.
Any help in this would be highly appreciable.

Thanks
Binny


Most likely the parameter to your query is incorrect. What is the datatype of the column in database for which you are passing int parameter.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 3:44 pm 
Newbie

Joined: Thu Dec 22, 2005 5:53 pm
Posts: 4
Hi the data type is a VARCHAR. As i mentioned it works fine with the MS SQL database.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 3:46 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
if the datatype is varchar use setString instead of setInt. Also post the mapping file also.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 4:23 pm 
Newbie

Joined: Thu Dec 22, 2005 5:53 pm
Posts: 4
Yes i am doing a setString only in my Query.

i am posting the mapping file.

**********************************************************
?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.mypackage.ClassStatus">
<meta attribute="class-code"> static final long serialVersionUID = -2498036496345162848L;</meta>
<id name="id" type="long">
<generator class="increment"/>
</id>
<property name="testNum" type="java.lang.String"/>
<property name="testTypeCd" type="java.lang.String"/>
</class>
<query name="ClassStatusQuery">
<![CDATA[
select
new ClassStatus(
tab1.testNum,
tab1.testTypeCd

)
from Table1 as tab1
where tab1.tCol = ?
]]>
</query>
</hibernate-mapping>

**********************************************************
Here tCol is VARCHAR(50);
Am doing a query.setString(0,parameter);


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 4:41 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
still insufficient info. post java code , pojo code and also database structre of table


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.