开发者

ValidateSchema gives OverflowException

开发者 https://www.devze.com 2023-01-26 21:10 出处:网络
My table has several int(11) and int(11) nullable columns. My domain object has the same int and int? properties.

My table has several int(11) and int(11) nullable columns. My domain object has the same int and int? properties.

When I run ValidateSchema, I get an exception without a very good error message:

   at System.Convert.ToInt32(UInt64 value)
   at System.UInt64.System.IConvertible.ToInt32(IFormatProvider provider)
   at System.Convert.ToInt32(Object value)
   at NHibernate.Dialect.Schema.MySQLColumnMetadata..ctor(DataRow rs)
   at NHibernate.Dialect.Schema.MySQLTableMetadata.GetColumnMetadata(DataRow rs)
   at NHibernate.Dialect.Schema.AbstractTableMetadata.AddColumn(DataRow rs)
   at NHibernate.Dialect.Schema.AbstractTableMetadata.I开发者_如何转开发nitColumns(IDataBaseSchema meta)
   at NHibernate.Dialect.Schema.AbstractTableMetadata..ctor(DataRow rs, IDataBaseSchema meta, Boolean extras)
   at NHibernate.Dialect.Schema.MySQLTableMetadata..ctor(DataRow rs, IDataBaseSchema meta, Boolean extras)
   at NHibernate.Dialect.Schema.MySQLDataBaseSchema.GetTableMetadata(DataRow rs, Boolean extras)
   at NHibernate.Tool.hbm2ddl.DatabaseMetadata.GetTableMetadata(String name, String schema, String catalog, Boolean isQuoted)
   at NHibernate.Cfg.Configuration.ValidateSchema(Dialect dialect, DatabaseMetadata databaseMetadata)
   at NHibernate.Tool.hbm2ddl.SchemaValidator.Validate()

Doesn't look like the method does anything strange using reflector:

public MySQLColumnMetadata(DataRow rs) : base(rs)
{
    base.Name = Convert.ToString(rs["COLUMN_NAME"]);
    object obj2 = rs["CHARACTER_MAXIMUM_LENGTH"];
    if (obj2 != DBNull.Value)
    {
        base.ColumnSize = Convert.ToInt32(obj2);
    }
    obj2 = rs["NUMERIC_PRECISION"];
    if (obj2 != DBNull.Value)
    {
        base.NumericalPrecision = Convert.ToInt32(obj2);
    }
    base.Nullable = Convert.ToString(rs["IS_NULLABLE"]);
    base.TypeName = Convert.ToString(rs["DATA_TYPE"]);
}

I also have several DateTime and DateTime? on my model. I know nhibernate on mysql is a bit strange on DateTime's. Could this be the problem?


I added the nhibernate source, and found out it was due to a longtext column in my database. Not supported my the mysql dialect it seems.

EDIT:

And here's the fix I used to get around the issue. Don't know if it's just a workaround for my validation issue or a complete fix though...

0

精彩评论

暂无评论...
验证码 换一张
取 消