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: Quotes being replaced in custom dialect
PostPosted: Mon Aug 11, 2008 4:47 pm 
Newbie

Joined: Mon Aug 11, 2008 4:36 pm
Posts: 1
Problem: I'm working on a web application that requires the use of the Pervasive SQL 9.5 database. Rather than mess with making my own NHibernate driver and such, I decided to work with it via ODBC. The MsSql2000 dialect most closely resembles that of PSQL, except for one thing: escaping reserved words.

MsSql2000 uses brackets: [ and ]. PSQL uses quotes. I created a new dialect based on MsSql2000Dialect and overrode OpenQuote and CloseQuote to make both return the correct character:

Code:
public override char OpenQuote {
   get { return '"'; }
}

public override char CloseQuote {
   get { return '"'; }
}


However, as you can see from the resulting SQL, the quotes are being replaced with two single quotes, thus making the statement invalid.

Any ideas why this is happening?

Hibernate version: NHibernate 1.2.0.4000

Full stack trace of any exception that occurs:

Code:
StackTrace:
   at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
   at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
   at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
   at System.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Odbc.OdbcCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
   at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session)
   at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
   at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
   at NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, Type optionalEntityName, Object optionalIdentifier, IEntityPersister persister)


Name and version of the database you are using: Pervasive SQL 9.5 via ODBC

The generated SQL (show_sql=true):

Code:
SELECT employee0_.EmployeeNbr as Employee1_0_0_, employee0_.InquiryName as InquiryN2_0_0_, employee0_.Name as Name0_0_, employee0_.QINACTIVE as QINACTIVE0_0_, employee0_.''PASSWORD'' as column5_0_0_, employee0_.SecurityMask as Security6_0_0_ FROM Employee employee0_ WHERE employee0_.EmployeeNbr=?


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.