Mapping a boolean field to char in nhibernate
When you work with legacy database is not infrequent that boolean value are mapped to char(1) field in databse, with Y/N or 0/1 or some other chars. In the literature there are a lot of solution, you can find for example a discussion here. When you use a user type to handle this kind of situation when you build HQL query you cannot use true or false in condition, for example
Select o from Orders where o.IsProcessed = false
This usually lead to a SQL error because you are trying to compare a char(1) column with the value false. The solution is to use this setting in the setting file.
|
|
This permits to substitue the value true with the literal 1 and false with the literal 0, but you can use whatever constant you want.
Alk.