Fixed
Details
Details
Assignee
Alex Zaytsev
Alex ZaytsevReporter
Volker Röppischer
Volker RöppischerLabels
Components
Fix versions
Affects versions
Priority
Who's Looking?
Open Who's Looking?
Created August 15, 2011 at 9:21 PM
Updated May 1, 2017 at 3:42 AM
Resolved April 30, 2015 at 2:54 AM
Boolean values are mapped as implementation of IUserType. The type implementation writes -1 for true values and 0 for false values
to database but allows to use bool properties in the application.
The query:
var pList = Session.Query<Test>().Where( c => c.Active ).ToList();
fails with the following exception:
NHibernate.QueryException: Unable to render boolean literal value [.Where[Core.Test.Domain.Test]
(NHibernate.Linq.NhQueryable`1[Core.Test.Domain.Test], Quote((c, ) => (c.Active)), )]
---> System.InvalidCastException: Das Objekt des Typs "NHibernate.Type.CustomType" kann nicht
in Typ "NHibernate.Type.BooleanType" umgewandelt werden.
A query using QueryOver :
var pList = Session.QueryOver<Test>().Where( t => t.Active ).List().ToList();
succeeds and produces the correct SQL:
NHibernate: SELECT this_.TEST_ID as TEST1_14_0_, this_.DESCRIPTION as DESCRIPT2_14_0_, this_.ACTIVE as ACTIVE14_0_,
this_.CAT_ID as CAT4_14_0_ FROM T_TEST this_ WHERE this_.ACTIVE = @p0;@p0 = -1 [Type: Int16 (0)]
An complete example with failing test can be found here https://github.com/Belvasis/NHTests
P.S.: Since this is my first issue entry here, i hope that the description and form is correct.