hi crash.
Customizing dialect will not help, because
TimestampResolutionInTicks is used to calculate new value for your timestamp column. It is not related to WHERE part of the statement (where timestamp = oldStampValue).
Problem is in nhibernate
NHibernate.Type.TimestampType class, which is based on
DbType.DateTime. As far as it is based on
DateTime, milliseconds will be ignored executing
OracleCommand and no mater if command will be used from
System.Data.OracleClient or
Oracle.DataAccess.Client.
After some debugging and modifications, I detected that if
TimestampType depends on
DbType.Time (not on
DbType.DateTime), then setting
DbType.Time to
OracleParameter class you get oracle type equal to
OracleType.Timestamp as parameter type. And his is correct. Unfortunately,
OracleParameter from
Oracle.DataAccess and
System.Data.OracleClient works differently when setting
DbType.Time (one maps to
OracleType.Timestamp, another to
OracleType.DateTime).
So, first I updated config file to use
NHibernate.Driver.OracleDataClientDriver instead of
NHibernate.Driver.OracleClientDriver and added assembly
Oracle.DataAccess.dll to my project. Then I made some dirty reflection modifications of hibernate
TypeFactory (why not to provide legal way to modify existing types or add new types from dialect?), which is responsible for type handling. Now it works fine. Factory modification code you should execute once on your application.
Code:
static AnyClass()
{
AnyClass.FixHibernateTimestampForOracle();
}
private static void FixHibernateTimestampForOracle()
{
Type dataType = typeof(TypeFactory);
String name4typeByTypeOfName = "typeByTypeOfName";
FieldInfo[] finfo = dataType.GetFields(BindingFlags.Static | BindingFlags.NonPublic);
FieldInfo myInfo = null;
for (int i = 0; myInfo == null && i < finfo.Length; i++)
{
FieldInfo info = finfo[i];
if ( name4typeByTypeOfName.Equals(info.Name))
{
myInfo = info;
}
}
if (myInfo != null)
{
// override hibernate timestamp
Hashtable typeByTypeOfName = (Hashtable) myInfo.GetValue(null);
FixedTimestampType typeTimestamp = new FixedTimestampType();
typeByTypeOfName[typeTimestamp.Name] = typeTimestamp;
}
return;
}
where new timestamp class is
Code:
public class FixedTimestampType : TimestampType
{
public override SqlType SqlType
{
get { return SqlTypeFactory.Time; }
}
}
best regards,
i5riza