我需要验证架构,其中我有一个具有 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);
}
}