詳細が提供されていないmappingexceptionのトラブルシューティング方法についてサポートが必要です。えーと、わかりました。クラスやプロパティだけでなく、詳細がたくさんあります。
手始めに、NH3.1とFNH1.2にアップグレードしました。NHibernate(3.1.0.4000)用のSQLiteデータベースを構築するために使用するクラスがあります。問題となっているfluent-nhibernate(1.2.0.712)マッピングを分離しようとして問題が発生しています。
エラーは次のとおりです。
System.InvalidCastException: Unable to cast object of type 'NHibernate.Type.SerializableType' to type 'NHibernate.Type.IIdentifierType'.
at NHibernate.Engine.UnsavedValueFactory.GetUnsavedIdentifierValue(String unsavedValue, IGetter identifierGetter, IType identifierType, ConstructorInfo constructor)
NHibernate.MappingException: Bad identifier type: System.Guid
at NHibernate.Engine.UnsavedValueFactory.GetUnsavedIdentifierValue(String unsavedValue, IGetter identifierGetter, IType identifierType, ConstructorInfo constructor)
at NHibernate.Tuple.PropertyFactory.BuildIdentifierProperty(PersistentClass mappedEntity, IIdentifierGenerator generator)
at NHibernate.Tuple.Entity.EntityMetamodel..ctor(PersistentClass persistentClass, ISessionFactoryImplementor sessionFactory)
at NHibernate.Persister.Entity.AbstractEntityPersister..ctor(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory)
at NHibernate.Persister.Entity.SingleTableEntityPersister..ctor(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, IMapping mapping)
at NHibernate.Persister.PersisterFactory.CreateClassPersister(PersistentClass model, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, IMapping cfg)
at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at MYPROJ.DatabaseConfigurer.OpenSession(DbEnum database) in DatabaseConfigurer.cs: line 37
at MYPROJ.user_specification.<.ctor>b__5() in UserSpecs.cs: line 670
GUID?何のガイド?マッピングのどこにも識別子としてのGUIDがありません。1つのクラスにプロパティとして1つのGUIDがあります。GUIDを使用して、サービスで処理するためにレコードをバッチ処理します。識別子ではありません。
fluent-nhibernate(1.2.0.712)を使用してメモリ内のSQLiteConfigurationをインスタンス化すると、次の行でエラーが発生します。
var sessionFactory = configuration.BuildSessionFactory();
log4netの基本構成をオンにしてファイルにログを記録しましたが、エラーが見つかりません。そのログの末尾は次のとおりです。
2011-05-12 15:29:04,152 [1] ?.lambda_method(:0) - processing filters (second pass)
2011-05-12 15:29:04,199 [1] ?.lambda_method(:0) - Using dialect: NHibernate.Dialect.SQLiteDialect
2011-05-12 15:29:04,277 [1] ?.lambda_method(:0) - Using dialect defined converter
2011-05-12 15:29:04,277 [1] ?.lambda_method(:0) - Generate SQL with comments: disabled
2011-05-12 15:29:04,277 [1] ?.lambda_method(:0) - Initializing connection provider: NHibernate.Connection.DriverConnectionProvider
2011-05-12 15:29:04,277 [1] ?.lambda_method(:0) - Configuring ConnectionProvider
2011-05-12 15:29:04,277 [1] ?.lambda_method(:0) - Transaction factory: NHibernate.Transaction.AdoNetWithDistributedTransactionFactory
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Optimize cache for minimal puts: False
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Connection release mode: on_close
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Default batch fetch size: 1
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - echoing all SQL to stdout
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Statistics: disabled
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Deleted entity synthetic identifier rollback: disabled
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Query translator: NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Query language substitutions: {'true'='1', 'false'='0'}
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - cache provider: NHibernate.Cache.NoCacheProvider, NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Wrap result sets: disabled
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Batcher factory: NHibernate.AdoNet.NonBatchingBatcherFactory, NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Default entity-mode: Poco
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Named query checking : enabled
2011-05-12 15:29:04,324 [1] ?.lambda_method(:0) - building session factory
2011-05-12 15:29:04,324 [1] ?.lambda_method(:0) - Session factory constructed with filter configurations : {}
2011-05-12 15:29:04,324 [1] ?.lambda_method(:0) - instantiating session factory with properties: {'connection.provider'='NHibernate.Connection.DriverConnectionProvider', 'proxyfactory.factory_class'='NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle', 'connection.driver_class'='NHibernate.Driver.SQLite20Driver, NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4', 'dialect'='NHibernate.Dialect.SQLiteDialect, NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4', 'hibernate.dialect'='NHibernate.Dialect.SQLiteDialect, NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4', 'query.substitutions'='true=1;false=0', 'connection.release_mode'='on_close', 'show_sql'='true', 'connection.connection_string'='Data Source=:memory:;Version=3;New=True;'}
2011-05-12 15:29:04,324 [1] ?.lambda_method(:0) - Obtaining IDbConnection from Driver
2011-05-12 15:29:04,324 [1] ?.lambda_method(:0) - Closing connection
Log4netは洞察を提供しませんでしたが、この例外をデバッグしてクラスまたはプロパティを明らかにする別の方法はありますか?
ありがとう
編集 私は主キーを設定するためにIIdConventionを使用し、ズボンが燃えています。ErrorIdのGUIDを持つElmahを使用しています。整数の適切なUnsavedValueセットと、ElmahのGuidについて、慣例で着信インスタンスをテストできるかどうかを確認します。明日これをテストして答えを投稿します。