If you use NHibernate TimeStamp type, your system will issue SQL commands with parameters of type DbType.DateTime which is mapped to the SQL Server datetime type in SQL Client. There you don't have the Millisecond precision.
If you want to be woking with high resolution DateTime values in SQL Server, you have to use DateTime2. I dont't use Oracle currently but it may be the case that ODP does not support the DbType.DateTime2 at all and you get exceptions there. If you use DbType.DateTime SQL Server Client will already do the rounding to the DATETIME data type resolution of 1/300s before sending the value to the database. Having a look at the NHibernate code I found that some drivers do a data type transformation in the InitializeParameter method. Maybe you could go with DateTime2Type und transform that to the SqlTypeFactory.DateTime. I don't consider using DateTime2 as a workaround because the whole DateTime and Timestamp implementation in NHibernate is oriented on old SQL Server versions or the DbType enum in *ADO.NET* <http://ado.net/> which is a little bit messy. The DateTime2 was added when Microsoft started to support high-resolution DateTime values on the database. CSharper Am Dienstag, 27. Mai 2014 16:12:26 UTC+2 schrieb [email protected]: > Some additional information from my experiments: > > When I use Criteria API to select rows basing on LastModified e.g. > ...Expression.Gt("LastModified", > myTimestamp) > then it works fine on Oracle (1 ms precision is available) but fails on > SQL Server (i can't get below 3 ms precision) > > If I change queries to HQL and use query.SetDateTime2("myTimestamp", > myTimestamp) then it works fine on SQL Server (1 ms precision is > available), but fails on Oracle (ArgumentException when preparing query) > If I use query.SetTimestamp(...) then it works fine on Oracle, but on SQL > Server still does not allow to get less than 3 ms precision. > > Bartek > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.
