0
私はEmployeeId#を自動的にインクリメントしたいと思います。これはビジネスIDであり、db id(hiloが生成されたID)と同じではありません。私はpromising solutionのように見えましたが、それを実装するのに問題があります。idではないNHibernateインクリメントカラム
マッピングが正しくない、SQLiteが処理できないなどの理由で、例外が発生しているかどうかはわかりません。誰かがこれに対して別の解決策を持っているかどうかを知りたいと思います。
乾杯、
ベリーALTER TABLEのSQLite文のhereためのフローチャートで
マッピング
<class name="Resource" table="Resources" ...>
<id name="Id" type="System.Int32" unsaved-value="0">
<column name="ResourceId" />
<generator class="hilo" />
</id>
...
<component name="EmployeeNumber" unique="true">
<property name="StorageValue" generated="always" insert="false">
<column name="EmployeeNumber" />
</property>
</component>
...
</class>
<database-object>
<create>
ALTER TABLE Entity DROP COLUMN EmployeeNumber
ALTER TABLE Entity ADD EmployeeNumber INT IDENTITY
</create>
<drop>
ALTER TABLE Entity DROP COLUMN EmployeeNumber
</drop>
</database-object>
EXCEPTION出力
ALTER TABLE Entity DROP COLUMN EmployeeNumber
ALTER TABLE Entity ADD EmployeeNumber INT IDENTITY
ALTER TABLE Entity DROP COLUMN EmployeeNumber
ALTER TABLE Entity ADD EmployeeNumber INT IDENTITY
failed: System.Exception : Generate schema error:
----> System.Data.SQLite.SQLiteException : SQLite error
near "DROP": syntax error
NHibernate\DbConfiguration\NHibInitialization\SchemaManager.cs(58,0): at Smack.Core.Data.NHibernate.DbConfiguration.NHibInitialization.SchemaManager._generateNewDb(Configuration cfg, IDbConnection conn)
NHibernate\DbConfiguration\NHibInitialization\SchemaManager.cs(16,0): at Smack.Core.Data.NHibernate.DbConfiguration.NHibInitialization.SchemaManager.GenerateNewDb(Configuration cfg, IDbConnection connection)
NHibernate\TestFixtures\SQLite\SQLiteBaseTestFixture.cs(56,0): at Smack.Core.TestingSupport.NHibernate.TestFixtures.SQLite.SQLiteBaseTestFixture._buildSchema()
NHibernate\TestFixtures\SQLite\SQLiteBaseTestFixture.cs(37,0): at Smack.Core.TestingSupport.NHibernate.TestFixtures.SQLite.SQLiteBaseTestFixture._SetUpNHibernateSession()
NHibernate\TestFixtures\SQLite\SQLiteBaseTestFixture.cs(25,0): at Smack.Core.TestingSupport.NHibernate.TestFixtures.SQLite.SQLiteBaseTestFixture.OnSetUp()
Mappings\EmployeeMappingTests.cs(23,0): at Smack.ConstructionAdmin.Data.Tests.Mappings.EmployeeMappingTests.OnSetUp()
BaseTestFixture.cs(27,0): at Smack.Core.TestingSupport.BaseTestFixture.SetUp()
--SQLiteException
at System.Data.SQLite.SQLite3.Prepare(SQLiteConnection cnn, String strSql, SQLiteStatement previous, UInt32 timeoutMS, String& strRemain)
at System.Data.SQLite.SQLiteCommand.BuildNextCommand()
at System.Data.SQLite.SQLiteCommand.GetStatement(Int32 index)
at System.Data.SQLite.SQLiteDataReader.NextResult()
at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)
at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()