NHibernate adonet.batch_size Not working

I have adonet.batch_size set to 10, but when I do a save on an object graph, it will save the object and all its children in a separate database call.

I can see this with the NHProf tool.

-- statement #1
INSERT INTO Preferences
-- statement #2
INSERT INTO PreferencesToWidgets
-- statement #3
INSERT INTO PreferencesToWidgets
-- statement #4
INSERT INTO PreferencesToWidgets
-- statement #5
INSERT INTO PreferencesToWidgets
-- statement #6
INSERT INTO PreferencesToWidgets
-- statement #7
INSERT INTO PreferencesToWidgets
-- statement #8
INSERT INTO PreferencesToWidgets
-- statement #9
INSERT INTO PreferencesToWidgets
-- statement #10
INSERT INTO PreferencesToWidgets
-- statement #11
INSERT INTO PreferencesToWidgets
-- statement #12
INSERT INTO Users

Users are tied to each other according to preferences | Many-to-One Preferences in PreferencesToWidgets

Basically, I have a user to whom I add a preference, and this preference has a bunch of widgets added to it.

Then I call session.SaveOrUpdate (user) and all objects are inserted into separate calls, even if the batch size is 10.

I am tuning through FluentNHibernate.

Fluently.Configure ()
.Database(FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2005.ConnectionString(c => c.FromConnectionStringWithKey( connectionStringKey ) )
.ProxyFactoryFactory( "NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu" ) )
.Mappings( m => m.FluentMappings.AddFromAssembly( typeof( SessionFactoryFactory ).Assembly ) )
.ExposeConfiguration( cfg => cfg.SetProperty( "generate_statistics", "true" ) )
.ExposeConfiguration( cfg => cfg.SetProperty( "adonet.batch_size", "10" ) )
.BuildSessionFactory();
+3
1

, . , SQL Server , . NHProf, .

INSERT INTO PreferencesToWidgets
...
select SCOPE_IDENTITY()

NHibernate 2.1.0.4000, ,

+9

Source: https://habr.com/ru/post/1714090/


All Articles