-->
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: query w/ trimmed parameter to Oracle NCHAR fails
PostPosted: Thu Feb 28, 2008 7:09 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
Hibernate version: 1.2.1

I'm trying to run an HQL query with a parameter that's compared to an Oracle NCHAR column. The query looks something like

Code:
FROM Foo
WHERE Foo.Bar = :bar


If the bar parameter is set to something like 'bar', and the Oracle NCHAR column is longer than the parameter text, it does not match. It does match if I right-pad the parameter value to the column length.

I've tried this using the same schema (NCHAR column) in SQL Server and it works fine. Using a literal value, like this:

Code:
FROM Foo
WHERE Foo.Bar = 'bar'


works against the same Oracle database.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 29, 2008 4:44 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
I was able to fix it by defining a custom type based on a user type with a DbType of System.Data.DbType.StringFixedLength (not sure why there isn't a standard StringFixedLength type in NHibernate) and then explicitly specifying that custom type whenever IQuery.SetParameter() is called with a string parameter.


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.