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=?