NHibernate Date type converts to NULL
Description
Environment
is duplicated by
Activity

Frédéric Delaporte September 21, 2017 at 9:32 AM
That would be a log warn only obsolescence: this can be set in the mapping, which would not generate any compilation warning.

Alex Zaytsev September 21, 2017 at 9:28 AM
I would like to remove the ability to configure the default value for DateType (through obsoleting)

Frédéric Delaporte September 21, 2017 at 9:26 AM
Agreed with letting the DB fail instead of silently replacing with NULL
. Breaking change of course.
But that base value will still have an usage: serves as a default value when the type is used as an identifier. Does it deserves a driver/dialect dependent value resolution? I do not think, this is quite an edge case and can still be coped with by specifying the BaseValue
parameter on the DateType
type. (Moreover access to DefaultValue
of type does not currently provide the session, so it would need some more breaking changes to fix.)
Looking at the DateTimeType
, it has also a base value, but this is the .Net Framework DateTime.MinValue
and its current only purpose is to server as a DefaultValue
. Should we realign DateType
on this? (May be an additional breaking change for those using this type for an identifier.) Additionally this default value has no parameter for being changed on DateTimeType
. Those date types are really a bit messy.

Alex Zaytsev September 21, 2017 at 4:53 AM
We need to make some decision whether we are removing the conversion to null or making the BaseValue driver specific. what do you think? I'm leaning towards removing the conversion and let the DB fail.

Alex Zaytsev September 21, 2017 at 4:48 AM
There are some comments in with the explanations how to fix
Details
Details
Assignee

Reporter

Database: SQL Server 2008 with the SQL Server 2008 dialect
We have a CLR DateTime property mapped to a NHibernate Date type.
Year 1752 in the CLR type converts to an empty string when NHibernate tries to insert a row in the database table.
The SQL Server type Date handles dates down to year 0001.
CLR type DateTime also handles dates of year 0001.
But, it seems like NHibernate type Date can not handle dates lower than ~1753, and therefor is not a perfect match with the other types.