-->
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: What don`t I understand about java.lang.Boolean mapping?
PostPosted: Fri Oct 29, 2004 2:26 pm 
Newbie

Joined: Fri Oct 29, 2004 1:05 pm
Posts: 10
I'm having a hard time figuring out how to set up yes_no types to serve java.lang.Boolean values. I used to have it set up as a "java.lang.Boolean" value. That worked well with Firebird. But now, I have to move to SQL-Server, while keeping the same data structure. Whenever I try to insert a value in SQL-Server that contains the java.lang.Boolean type, there is a conversion to the "bit" type. I tried to change the query substitutions but I am still getting the error.

Conceptually, this seems like a no-brainer to me. Yet, it looks like I'm not understand something in the mapping flow. Is there something wrong with my setup or am I misunderstanding something or do I have to use a custom boolean type to make it work?

If my setup is wrong, what is wrong with it?

If I'm misunderstanding, what is it?

If I'm forced to use a custom boolean type, well, I guess I can figure how to do that but I think that's overkill. Hibernate offers everything I need.

Thanks,

L


Hibernate version: 2.1.6

Mapping documents:
Code:
#Hibernate properties for fmstatic
#Fri Oct 29 13:53:27 EDT 2004
hibernate.connection.username=sa
hibernate.connection.password=
hibernate.dialect=net.sf.hibernate.dialect.SQLServerDialect
hibernate.show_sql=false
hibernate.connection.url=jdbc\:jtds\:sqlserver\://localhost\:1433;DatabaseName\=TmeData
hibernate.connection.driver_class=net.sourceforge.jtds.jdbc.Driver
hibernate.connection.provider_class=net.sf.hibernate.connection.C3P0ConnectionProvider
hibernate.query.substitutions=true 'Y', false 'N', yes 'Y', no 'N'


And for the class that interests me:

Code:
        <property
            name="userDefined"
            type="yes_no"
            update="true"
            insert="true"
            access="property"
            column="user_defined"
            not-null="true"
        />


My SQL scripts looks like this:

Code:
sp_addtype boolean, 'char(1)';

create table Profile
(
   id UUID not null,
   name NAMETYPE unique,
   fw_id UUID not null,
   hw_id UUID not null,
   user_defined BOOLEAN,
   constraint PK_Profile primary key (id)
);


Full stack trace of any exception that occurs: I'm using the jtds driver.

Code:
Oct 29, 2004 1:54:06 PM net.sf.hibernate.JDBCException <init>
SEVERE: Could not execute query
java.sql.SQLException: Syntax error converting the varchar value 'N' to a column of data type bit.
   at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:367)
   at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2217)
   at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:1696)
   at net.sourceforge.jtds.jdbc.TdsCore.isDataInResultSet(TdsCore.java:670)
   at net.sourceforge.jtds.jdbc.JtdsResultSet.<init>(JtdsResultSet.java:139)
   at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:277)
   at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:634)
   at com.mchange.v2.sql.filter.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:68)
   at com.mchange.v2.c3p0.impl.C3P0PooledConnection$2.executeQuery(C3P0PooledConnection.java:567)
   at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
   at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
   at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
   at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1544)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1521)

Name and version of the database you are using: SQL Server 2000


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.