Hi,
I am using nhibernate 1.2.0 with Firebird 1.5. My map file like this:
Code:
<property column="SCHOOLForm" type="YesNo" name="SchoolForm" not-null="true" length="1"/>
In my HQL, my query looks like this:
Code:
where en.SchoolForm = :schoolForm
Then I am using SetBoolean("schoolForm", false) to set the value to False. I am assume nhibernate would set the value to "N", but when I look at nhibernate log, it looks like this:
Code:
11:36:32.931 [5] DEBUG NHibernate.Loader.Loader - BindNamedParameters() False -> schoolForm [1]
11:36:32.931 [5] DEBUG NHibernate.Type.BooleanType - binding 'False' to parameter: 1
It seems bind 'False' to the query. Is something wrong with my setups?
In nhibernate-development list, Fabio Maulo suggest me to change like this:
The solution is type="Boolean".
Take a look to the hibernate.cfg.xml at:
Code:
<property name="query.substitutions">true 1, false 0, yes 1, no 0</property>
If you want map the property to a VARCHAR(1) use:
Code:
<property name="query.substitutions">true Y, false N, yes Y, no N</property>
But after I change to Boolean type, it become worse, nhibernate raise follow error
Code:
---> NHibernate.ADOException: could not execute query
---> System.FormatException: String was not recognized as a valid Boolean.
at System.Boolean.Parse(String value)
at System.String.System.IConvertible.ToBoolean(IFormatProvider provider)
at System.Convert.ToBoolean(Object value)
at NHibernate.Type.BooleanType.Get(IDataReader rs, Int32 index)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
at NHibernate.Type.AbstractType.Hydrate(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
at NHibernate.Loader.Loader.Hydrate(IDataReader rs, Object id, Object obj, ILoadable persister, ISessionImplementor session, String[][] suffixedPropertyColumns)
at NHibernate.Loader.Loader.LoadFromResultSet(IDataReader rs, Int32 i, Object obj, Type instanceClass, EntityKey key, LockMode lockMode, ILoadable rootPersister, ISessionImplementor session)
at NHibernate.Loader.Loader.InstanceNotYetLoaded(IDataReader dr, Int32 i, ILoadable persister, EntityKey key, LockMode lockMode, EntityKey optionalObjectKey, Object optionalObject, IList hydratedObjects, ISessionImplementor session)
at NHibernate.Loader.Loader.GetRow(IDataReader rs, ILoadable[] persisters, EntityKey[] keys, Object optionalObject, EntityKey optionalObjectKey, LockMode[] lockModes, IList hydratedObjects, ISessionImplementor session)
at NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, LockMode[] lockModeArray, EntityKey optionalObjectKey, IList hydratedObjects, EntityKey[] keys, Boolean returnProxies)
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.DoList(ISessionImplementor session, QueryParameters queryParameters)
Does anyone give me a hint please?
Cheers,
Tao