NHibernate 3.1 breaks my code, oder?
I have recently downloaded and installed NHibernate 3.1. There are 2 new DLL's which I copied over the 3.0 installation. Ques开发者_开发百科tion #1: Is this all I need to do?
In my system I have implemented a custom id generator, it works with 3.0 but I get an error 'Could not interpret id generator strategy' with 3.1, no other changes were made. Question #2: What has changed in 3.1 that what I did in 3.0 no longer works?
Here is an example of my custom generator class.
public class IdGenerator : TableGenerator
{
public override object Generate(ISessionImplementor session, object obj)
{
if(session.Connection.ToString().ToLower().IndexOf("sqlclient") > 0)
{
IQuery query = session.GetNamedSQLQuery("GenerateSQLServerId");
return Convert.ToInt32(query.UniqueResult());
}
else if (session.Connection.ToString().ToLower().IndexOf("oracle") > 0)
{
IQuery query = session.GetNamedSQLQuery("GenerateOracleId");
return query.List()[0];
}
return null;
}
}
And in my hbm.xml file I have:
<id name="Id" column="ID" type="int">
<generator class="Namespace.IdGenerator, Namespace" />
</id>
Like I said, it all worked fine with 3.0, but not with 3.1. Perhaps it's an installation problem...any ideas?
Question #1 - This is all I did and looks like I am on version 3.1 now.
Question #2 - I use a class library to host all my functionality with NHibernate and then a consolse application to test before I implement my new methods into the system. I changed the References to 3.1 in my console application and forgot to do the same in my class library. Once I got both on the same version the error message 'Could not interpret id generator strategy' went away and everything worked fine. There was and is nothing wrong with my custom generator.
精彩评论