[b]Hibernate version: [/b]
1.2.0.4000
[b]Mapping documents:[/b]
<?xml version='1.0' encoding='utf-8'?>
<hibernate-mapping assembly='TestMappingNHibernate' namespace='TestMappingNHibernate' xmlns='urn:nhibernate-mapping-2.2'>
<class name='TestOne' table='test'>
<id name='Id' column='id'>
<generator class='native'/>
</id>
<map name='Values' table='testvalues' cascade='save-update'>
<key column='testId' />
<index column='`Key`' type='int' />
<element column='`Value`' type='int' />
</map>
</class>
</hibernate-mapping>
[b]Code between sessionFactory.openSession() and session.close():[/b]
TestOne test = new TestOne ( );
test.Values.Add ( 12, 54 );
session.Save ( test );
[b]Full stack trace of any exception that occurs:[/b]
none.
[b]Name and version of the database you are using:[/b]
Sql Server 2005
[b]The generated SQL (show_sql=true):[/b]
NHibernate: INSERT INTO test.test DEFAULT VALUES; select SCOPE_IDENTITY()
[b]Debug level Hibernate log excerpt:[/b]
2008-03-12 17:23:44,576 [11] INFO NHibernate.Cfg.Environment [(null)] - NHibernate 1.2.0.4000 (1.2.0.4000)
2008-03-12 17:23:44,623 [11] INFO NHibernate.Cfg.Environment [(null)] - nhibernate section not found in application configuration file
2008-03-12 17:23:44,623 [11] INFO NHibernate.Cfg.Environment [(null)] - Bytecode provider name : lcg
2008-03-12 17:23:44,623 [11] INFO NHibernate.Cfg.Environment [(null)] - Using reflection optimizer
2008-03-12 17:23:44,639 [11] DEBUG NHibernate.Cfg.Configuration [(null)] - dialect=NHibernate.Dialect.MsSql2005Dialect
2008-03-12 17:23:44,639 [11] DEBUG NHibernate.Cfg.Configuration [(null)] - connection.driver_class=NHibernate.Driver.SqlClientDriver
2008-03-12 17:23:44,639 [11] DEBUG NHibernate.Cfg.Configuration [(null)] - connection.connection_string_name=ConnectionString
2008-03-12 17:23:44,639 [11] DEBUG NHibernate.Cfg.Configuration [(null)] - show_sql=true
2008-03-12 17:23:44,639 [11] DEBUG NHibernate.Cfg.Configuration [(null)] - use_outer_join=true
2008-03-12 17:23:44,639 [11] DEBUG NHibernate.Cfg.Configuration [(null)] - hibernate.default_schema=test
2008-03-12 17:23:44,639 [11] DEBUG NHibernate.Cfg.Configuration [(null)] - <-TestMappingNHibernate
2008-03-12 17:23:44,639 [11] INFO NHibernate.Cfg.Configuration [(null)] - Searching for mapped documents in assembly: TestMappingNHibernate
2008-03-12 17:23:44,670 [11] INFO NHibernate.Cfg.Configuration [(null)] - Adding embedded mapping document: TestMappingNHibernate.TestOne.hbm.xml
2008-03-12 17:23:44,670 [11] INFO NHibernate.Cfg.Configuration [(null)] - Mapping resource: TestMappingNHibernate.TestOne.hbm.xml
2008-03-12 17:23:44,701 [11] INFO NHibernate.Dialect.Dialect [(null)] - Using dialect: NHibernate.Dialect.MsSql2005Dialect
2008-03-12 17:23:44,733 [11] INFO NHibernate.Cfg.HbmBinder [(null)] - Mapping class: TestMappingNHibernate.TestOne -> test
2008-03-12 17:23:44,779 [11] DEBUG NHibernate.Cfg.HbmBinder [(null)] - Mapped property: Id -> id, type: Int32
2008-03-12 17:23:44,795 [11] INFO NHibernate.Cfg.HbmBinder [(null)] - Mapping collection: TestMappingNHibernate.TestOne.Values -> testvalues
2008-03-12 17:23:44,795 [11] DEBUG NHibernate.Cfg.HbmBinder [(null)] - Mapped property: Values, type: IDictionary`2
2008-03-12 17:23:44,811 [11] DEBUG NHibernate.Cfg.Configuration [(null)] - properties: System.Collections.Hashtable
2008-03-12 17:23:44,811 [11] INFO NHibernate.Cfg.Configuration [(null)] - processing one-to-many association mappings
2008-03-12 17:23:44,811 [11] DEBUG NHibernate.Cfg.CollectionSecondPass [(null)] - Second pass for collection: TestMappingNHibernate.TestOne.Values
2008-03-12 17:23:44,811 [11] DEBUG NHibernate.Cfg.CollectionSecondPass [(null)] - Mapped collection key: testId, index: Key, element: Value, type: Int32
2008-03-12 17:23:44,811 [11] INFO NHibernate.Cfg.Configuration [(null)] - processing one-to-one association property references
2008-03-12 17:23:44,811 [11] INFO NHibernate.Cfg.Configuration [(null)] - processing foreign key constraints
2008-03-12 17:23:44,811 [11] DEBUG NHibernate.Cfg.Configuration [(null)] - resolving reference to class: TestOne
2008-03-12 17:23:44,826 [11] INFO NHibernate.Dialect.Dialect [(null)] - Using dialect: NHibernate.Dialect.MsSql2005Dialect
2008-03-12 17:23:44,842 [11] INFO NHibernate.Connection.ConnectionProvider [(null)] - Configuring ConnectionProvider
2008-03-12 17:23:44,889 [11] INFO NHibernate.Cfg.SettingsFactory [(null)] - Optimize cache for minimal puts: False
2008-03-12 17:23:44,889 [11] INFO NHibernate.Cfg.SettingsFactory [(null)] - Connection release mode: auto
2008-03-12 17:23:44,889 [11] INFO NHibernate.Cfg.SettingsFactory [(null)] - Default schema set to: test
2008-03-12 17:23:44,889 [11] INFO NHibernate.Cfg.SettingsFactory [(null)] - echoing all SQL to stdout
2008-03-12 17:23:44,889 [11] INFO NHibernate.Cfg.SettingsFactory [(null)] - Query translator: NHibernate.Hql.Classic.ClassicQueryTranslatorFactory
2008-03-12 17:23:44,904 [11] INFO NHibernate.Cfg.SettingsFactory [(null)] - Query language substitutions: {}
2008-03-12 17:23:44,904 [11] INFO NHibernate.Cfg.SettingsFactory [(null)] - cache provider: NHibernate.Cache.NoCacheProvider, NHibernate, Version=1.2.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
2008-03-12 17:23:44,904 [11] INFO NHibernate.Impl.SessionFactoryImpl [(null)] - building session factory
2008-03-12 17:23:44,904 [11] DEBUG NHibernate.Impl.SessionFactoryImpl [(null)] - instantiating session factory with properties: {use_outer_join=true, dialect=NHibernate.Dialect.MsSql2005Dialect, connection.driver_class=NHibernate.Driver.SqlClientDriver, hibernate.use_reflection_optimizer=true, hibernate.connection.driver_class=NHibernate.Driver.SqlClientDriver, hibernate.show_sql=true, hibernate.connection.connection_string_name=ConnectionString, hibernate.default_schema=test, connection.connection_string_name=ConnectionString, hibernate.use_outer_join=true, hibernate.dialect=NHibernate.Dialect.MsSql2005Dialect, show_sql=true}
2008-03-12 17:23:45,092 [11] DEBUG NHibernate.Impl.SessionFactoryObjectFactory [(null)] - initializing class SessionFactoryObjectFactory
2008-03-12 17:23:45,108 [11] DEBUG NHibernate.Impl.SessionFactoryObjectFactory [(null)] - registered: f62888dc1b404df6be0ace98294e7f37(unnamed)
2008-03-12 17:23:45,108 [11] INFO NHibernate.Impl.SessionFactoryObjectFactory [(null)] - no name configured
2008-03-12 17:23:45,170 [11] DEBUG NHibernate.Loader.Entity.AbstractEntityLoader [(null)] - Static select for entity TestMappingNHibernate.TestOne: SELECT testone0_.id as id0_0_ FROM test.test testone0_ WHERE testone0_.id=?
2008-03-12 17:23:45,170 [11] DEBUG NHibernate.Loader.Entity.AbstractEntityLoader [(null)] - Static select for entity TestMappingNHibernate.TestOne: SELECT testone0_.id as id0_0_ FROM test.test testone0_ WHERE testone0_.id=?
2008-03-12 17:23:45,170 [11] DEBUG NHibernate.Loader.Entity.AbstractEntityLoader [(null)] - Static select for entity TestMappingNHibernate.TestOne: SELECT testone0_.id as id0_0_ FROM test.test testone0_ with (updlock, rowlock) WHERE testone0_.id=?
2008-03-12 17:23:45,170 [11] DEBUG NHibernate.Loader.Entity.AbstractEntityLoader [(null)] - Static select for entity TestMappingNHibernate.TestOne: SELECT testone0_.id as id0_0_ FROM test.test testone0_ with (updlock, rowlock) WHERE testone0_.id=?
2008-03-12 17:23:45,186 [11] DEBUG NHibernate.Loader.Collection.BasicCollectionLoader [(null)] - Static select for collection TestMappingNHibernate.TestOne.Values: SELECT values0_.testId as testId__0_, values0_.[Value] as Value2_0_, values0_.[Key] as Key3___0_ FROM test.testvalues values0_ WHERE values0_.testId=?
2008-03-12 17:23:45,186 [11] DEBUG NHibernate.Impl.SessionFactoryImpl [(null)] - Instantiated session factory
2008-03-12 17:23:45,186 [11] DEBUG NHibernate.Impl.SessionImpl [(null)] - opened session
2008-03-12 17:23:49,201 [11] DEBUG NHibernate.Impl.SessionImpl [(null)] - saving [TestMappingNHibernate.TestOne#<null>]
2008-03-12 17:23:49,201 [11] DEBUG NHibernate.Engine.Cascades [(null)] - processing cascades for: TestMappingNHibernate.TestOne
2008-03-12 17:23:49,217 [11] DEBUG NHibernate.Engine.Cascades [(null)] - done processing cascades for: TestMappingNHibernate.TestOne
2008-03-12 17:23:49,217 [11] DEBUG NHibernate.Impl.SessionImpl [(null)] - executing insertions
2008-03-12 17:23:49,217 [11] DEBUG NHibernate.Impl.WrapVisitor [(null)] - Wrapped collection in role: TestMappingNHibernate.TestOne.Values
2008-03-12 17:23:49,233 [11] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister [(null)] - Inserting entity: TestMappingNHibernate.TestOne (native id)
2008-03-12 17:23:49,233 [11] DEBUG NHibernate.Impl.BatcherImpl [(null)] - Opened new IDbCommand, open IDbCommands: 1
2008-03-12 17:23:49,233 [11] DEBUG NHibernate.Impl.BatcherImpl [(null)] - Building an IDbCommand object for the SqlString: INSERT INTO test.test DEFAULT VALUES; select SCOPE_IDENTITY()
2008-03-12 17:23:49,248 [11] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister [(null)] - Dehydrating entity: [TestMappingNHibernate.TestOne#<null>]
2008-03-12 17:23:49,248 [11] DEBUG NHibernate.SQL [(null)] - INSERT INTO test.test DEFAULT VALUES; select SCOPE_IDENTITY()
2008-03-12 17:23:49,326 [11] DEBUG NHibernate.Connection.DriverConnectionProvider [(null)] - Obtaining IDbConnection from Driver
2008-03-12 17:23:49,498 [11] DEBUG NHibernate.Impl.BatcherImpl [(null)] - Opened IDataReader, open IDataReaders: 1
2008-03-12 17:23:49,514 [11] DEBUG NHibernate.Type.Int32Type [(null)] - returning '7' as column:
2008-03-12 17:23:49,514 [11] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister [(null)] - Natively generated identity: 7
2008-03-12 17:23:49,514 [11] DEBUG NHibernate.Driver.NHybridDataReader [(null)] - running NHybridDataReader.Dispose()
2008-03-12 17:23:49,514 [11] DEBUG NHibernate.Impl.BatcherImpl [(null)] - Closed IDataReader, open IDataReaders :0
2008-03-12 17:23:49,514 [11] DEBUG NHibernate.Impl.BatcherImpl [(null)] - Closed IDbCommand, open IDbCommands: 0
2008-03-12 17:23:49,514 [11] DEBUG NHibernate.Impl.ConnectionManager [(null)] - aggressively releasing database connection
2008-03-12 17:23:49,514 [11] DEBUG NHibernate.Connection.ConnectionProvider [(null)] - Closing connection
2008-03-12 17:23:49,514 [11] DEBUG NHibernate.Engine.Cascades [(null)] - processing cascades for: TestMappingNHibernate.TestOne
2008-03-12 17:23:49,514 [11] DEBUG NHibernate.Engine.Cascades [(null)] - done processing cascades for: TestMappingNHibernate.TestOne
2008-03-12 17:23:49,514 [11] DEBUG NHibernate.Impl.SessionImpl [(null)] - running ISession.Dispose()
2008-03-12 17:23:49,514 [11] DEBUG NHibernate.Impl.SessionImpl [(null)] - closing session
2008-03-12 17:23:49,529 [11] DEBUG NHibernate.Impl.BatcherImpl [(null)] - running BatcherImpl.Dispose(true)
2008-03-12 17:23:49,529 [11] DEBUG NHibernate.Transaction.AdoTransaction [(null)] - running AdoTransaction.Dispose()
[b]Problem:[/b]
Basically, nothing gets inserted into the testvalues table.
What am I doing wrong?
I've debugged through the code, and it seems like NHibernate determines that types of "int" (the value type) don't need to be cascaded.
|