0

我需要验证架构,其中我有一个具有 byte[] 属性 (BLOB) 的对象。当我运行验证时,我收到 OverflowException:“对于 Int32,值太大或太小。”

我正在使用 NHibernate 3.1.0.400 和 FluentNHibernate 1.2.0.712 我已经创建了测试项目来检查它。这是代码(它在验证时掉落):

static void Main(string[] args)
    {
        var configuration = new NHibernate.Cfg.Configuration();

        string connectionString = "some connection string";
        Console.WriteLine("Running test with connection string: {0}", connectionString);
        Dictionary<string, string> props = new Dictionary<string, string>()
                                               {
                                                   {"connection.provider", "NHibernate.Connection.DriverConnectionProvider"},
                                                   {"connection.driver_class", "NHibernate.Driver.MySqlDataDriver"},
                                                   {"connection.connection_string", connectionString},
                                                   {"dialect", "NHibernate.Dialect.MySQL5Dialect"},
                                               };
        configuration.AddProperties(props);
        var mappings = Fluently.Configure(configuration)
            .Mappings(m => m
                               .FluentMappings.AddFromAssemblyOf<DataResource>()
                               .Conventions.AddFromAssemblyOf<DataResource>());

        var sessionFactory = mappings
               .ExposeConfiguration(DoExtendedConfiguration)
               .BuildSessionFactory();
    }

    private static void DoExtendedConfiguration(Configuration configuration)
    {
        SchemaExport schemaExport = new SchemaExport(configuration).SetDelimiter(";").SetOutputFile("schema.sql");
        schemaExport.Create(false, true);

        SchemaValidator schemaValidator = new SchemaValidator(configuration);
        schemaValidator.Validate();
    }

 public class DataResource
{
    public int Id { get; set; }
    public byte[] Value { get; set; }
}
public class DataResourceMap : ClassMap<DataResource>
{
    public DataResourceMap()
    {
        Id(x => x.Id);
        Map(x => x.Value);
    }
}
4

1 回答 1

0

我没有在官方上找到任何关于此类错误的提及,但在我将 FluentNhibernate 和 Nhibernate 更新到最后一个可用版本(通过 Nuget)后,问题解决了。这适合我,所以我将结束这个问题,就好像没有人找到任何其他解决方案并且堆栈允许我这样做。

于 2012-09-07T13:52:42.163 回答