Won't Fix
Details
Details
Assignee
Unassigned
UnassignedReporter
Tomer Avissar
Tomer AvissarComponents
Affects versions
Priority
Who's Looking?
Open Who's Looking?
Created October 21, 2010 at 7:46 AM
Updated December 8, 2010 at 3:59 PM
Resolved December 8, 2010 at 3:59 PM
When trying to save a NVARCHAR2 column (NVARCHAR2 is a column used in Oracle, to store Unicode string value in a non-Unicode database) with NHibernate, the data is not stored correctly (data stored is '?????').
The reason for that is the parameter built in NHibernate is setting the parameter type to be DbType.String"
OracleParameter.DbType = DbType.String;
In order to work with ODP.NET correctly you need to change the OracleDbType property, like this:
OracleParameter.OracleDbType = OracleDbType.NVarchar2;
The way I found to change this was on the OracleDataClientDriver class, on the InitializeParameter procedure, using reflection (because NHibernate does not have a reference to ODP.NET) like this:
switch (sqlType.DbType)
{
case DbType.String:
dbParam.ParameterName = FormatNameForParameter(name);
System.Type objType = dbParam.GetType();
PropertyInfo propIfo = objType.GetProperty("OracleDbType");
Object val = System.Enum.Parse(propInfo.PropertyType, "NVarchar2");
propInfo.SetValue(dbParam, val, null)
break;
}
This works for me, is there a better place where this could be handled?