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.  [ 4 posts ] 
Author Message
 Post subject: boolean - bit column mapping
PostPosted: Tue May 09, 2006 11:52 am 
Newbie

Joined: Wed May 03, 2006 9:49 am
Posts: 4
Nhibernate 1.0.2

In some of my persistant object s i have boolean properties mapped to bit columns in the DB (MS SQL).

On the SQL Server 2005 in my development lan it worked great but on the production SQL Server 2000 an exception is thrown beacuse of this mapping:

Syntax error converting the varchar value 'False' to a column of data type bit.

I am using the MsSql2000Dialect.

??


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 09, 2006 5:04 pm 
Newbie

Joined: Thu May 04, 2006 12:20 pm
Posts: 4
Hello

Are you using an HQL query to retrieve data?

I have a similar problem with oracle. I am mapping booleans to CHAR columns that are either Y or N. I am mapping the column using type="YesNo" but it seems that these mappings do not apply to HQL. I had to add this property to my configuration:

cfg.Properties["hibernate.query.substitutions"] =
"true='Y', false='N'";


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 10, 2006 9:31 am 
Newbie

Joined: Wed May 03, 2006 9:49 am
Posts: 4
hi,

yes am using Hql.
I've tried setting the substitions as you described but they do not seem to have any effect.

I've even tried to use the exact substitution you showed with the SQL2005 server (on which the mapping works fine) expecting an error (as i am using bit columns not char ones) but nothing happend.

If there something that needs to be done to 'activate' the quesry subsitions?

I am not loading individual mapping files but am using the Configuration.AddAsembly() method to load all mapping files followed by the query.substitution property.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 15, 2006 3:50 pm 
Newbie

Joined: Tue Aug 15, 2006 3:43 pm
Posts: 5
Greetings, I'm having a similar problem mapping a bit field to a boolean but in my case I'm having the issue when I try to insert a record into a SQL Sever 2000 bit field.

My property mapping is as such

<property name="Rohs" column="Rohs_Flag" not-null="true" type="Boolean"/>

I've got the query substitution defined as follows:
<property name="query.substitutions">True 1, False 0, yes 1, no 0</property>

When I try to persist a record with the Boolean set, HQL generates the following query:

INSERT INTO Staging_Area (Price, Mfr_Code, Rohs_Flag,...VALUES (@p0, @p1, @p2, @p3, ...);
@p0 = ''123"
@p1 = 'Foo'
@p2 = 'False'
@p(n)...

How can I make the insert statement generate a 1 or a 0 for True or False?
Must I use the formula attribute as in this post?

thanks,


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