These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Bug with Informix ADO.NET Provider and NHibernate
PostPosted: Fri Nov 02, 2007 4:41 pm 
Newbie

Joined: Fri Nov 02, 2007 4:27 pm
Posts: 1
I've mostly gotten NHibernate to play nice with the Informix ADO.NET provider, but I'm running into a problem with the way Enum parameters work. The offending code is in NHibernate.Type.PersistentEnumType:

Code:
public override void Set(IDbCommand cmd, object value, int index)
{
   IDataParameter par = (IDataParameter) cmd.Parameters[index];
   if (value == null)
   {
      par.Value = DBNull.Value;
   }
   else
   {
      par.Value = value; // <--- This is causing the problem
   }
}


When NHibernate sets the parameter value it assumes that the ADO.NET provider will convert the Enum type into the appropriate underlying type. This seems to work fine with most ADO.NET providers, but Informix chokes on it (it complains that the enumerated type is not blittable).

There is already a method in the same class called "GetValue", which is used to handle Oracle's improper type conversion by the provider, but it is only called from the "Get" method. I've found that adding a call to "GetValue" in the "Set" method solves my Informix problem. Any chance we can add this to the trunk? My patch is copied below:

Code:
Index: NHibernate/Type/PersistentEnumType.cs
===================================================================
--- NHibernate/Type/PersistentEnumType.cs   (revision 3071)
+++ NHibernate/Type/PersistentEnumType.cs   (working copy)
@@ -151,7 +151,7 @@
         }
         else
         {
-            par.Value = value;
+            par.Value = GetValue(value);
         }
      }


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.