I faced an issue while using the NHibernate with double byte character
search. This was workign fine with version 2.1. Once I migarted to
Version 3.0 double byte charcter search breaked. We know that we have
to give the column lenght in the mapping file for varchar field with
double byte characters. This is how it worked in 2.1.

Version 3.0 have a method called "CloneParameter" in DriverBase.cs.
All drivers inherit this class. This method clones the parameter to
new set of parameters. This was copying only the dbtype and value and
not the size of the column . Even other parameter values too.

Solution:

Inherit a class from NHibernate OdbcDriver in our case for informix.
For others inherit from your corresponding NHibernate driver classes.
Override the clone parameter and update it to copy the column sizes
too.

//Create a class to inherit from OdbcDriver
public class IfDriver:OdbcDriver
{
    protected override IDBDataParameter CloneParameter(IDBCommand
cmd,IDBDataParameter originalParameter)
    {
        vara param=cmd.CreateParameter();
        param.DBType=originalParameter.DBType;
        param.Value=originalParameter.Value;
        param.Size=originalParameter.Size;
       /// include other properties too if needed
        return param;
    }
}

//Mark your class to be used in NHibernate's config
NHibernate.Configuration cf=new NHibernate.Configuration();
IDictionary<string,string> props=new Dictionary<string,string>();
props.Add("connection.driver_class",typeof(IfDriver).AssemblyQualifiedName);
cf.SetProperties(props);


Feedback:
Please give me your feedback if my solution is ok.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to