Search code examples
mysqlnhibernatebatching

How to configure custom MySQL NHibernate Batcher?


NHibernate with MySQL Dialect does not support Batching out of the box. I have found custom MySQL Batcher for NHibernate on nuget. Also, following is the github link:

https://github.com/Andorbal/NHibernate.MySQLBatcher

But I do not know how to inject/set this into my hibernate.cfg.xml configuration.

How to configure custom MySQL NHibernate Batcher?


Solution

  • The property you need to set is call "adonet.factory_class". Use any of the following:

    <property name="adonet.factory_class">assembly-qualified-name</property>
    

    or

    configuration.SetProperty(
        Environment.BatchStrategy,
        typeof(MySqlClientBatchingBatcherFactory).AssemblyQualifiedName);
    

    or as noted in the readme of the batcher itself (https://github.com/Andorbal/NHibernate.MySQLBatcher):

    config.DataBaseIntegration(db =>
        db.Batcher<MySqlClientBatchingBatcherFactory>());