Connection Pooling in NHibernate

1,813 views
Skip to first unread message

teamsar muliadi

unread,
Feb 9, 2012, 10:00:21 AM2/9/12
to fluent-n...@googlegroups.com
Hi all,

I'm currently working with oracle as database and i almost getting error about "connection timeout" everyday.
I wanna ask you about how to configure NHibernate to be connection pool and how to set maximum pooling.
I've just added .Pool(true) but it doesn't work.. :(

public static ISessionFactory ConfigureSessionFactory()
        {
            return Fluently.Configure()
                .Database
                (
                    OracleClientConfiguration
                        .Oracle10
                        .ConnectionString(cs => cs
                            .Server(Server.Configurator.ServerConfigReader.StructureAppSettings.Server)
                            .Port(Server.Configurator.ServerConfigReader.StructureAppSettings.Port)
                            .Instance(Server.Configurator.ServerConfigReader.StructureAppSettings.Instance)
                            .Username(Server.Configurator.ServerConfigReader.StructureAppSettings.Username)
                            .Password(Server.Configurator.ServerConfigReader.StructureAppSettings.Password)
                            .Pooling(true)
                            )
                     .Driver<NHibernate.Driver.OracleDataClientDriver>().ShowSql()
                )
                .Mappings(m => m.AutoMappings.Add(() =>
                {
                    var model = new AutoPersistenceModel();
                    model.AddEntityAssembly(Assembly.GetExecutingAssembly())
                        .Where(t => t.Namespace.EndsWith("Server.PersisterService.Entities"));
                    return model;
                }))
                  
                .ExposeConfiguration(c =>
                {
                    c.SetProperty("current_session_context_class",
                                  "thread_static");
                    c.SetProperty("proxyfactory.factory_class",
                                  "NHibernate.ByteCode.LinFu.ProxyFactoryFactory,NHibernate.ByteCode.LinFu");
                    new SchemaUpdate(c).Execute(true, true);
                })
                .BuildSessionFactory();
        }

Thanks

--
Regard,


Teamsar Muliadi Panggabean

When System.Utils become 1010 1001 0111 0110 1111 0011


Cengiz Han

unread,
Feb 13, 2012, 3:40:29 PM2/13/12
to fluent-n...@googlegroups.com
What other tools that you use in your project?  Do you use long running threads in your project? Any IoC container with thread static scoping?
Do you close/dispose your session in transaction rollback scenarios?

--
You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group.
To post to this group, send email to fluent-n...@googlegroups.com.
To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.



--
cengiz han
blog:develoq

Reply all
Reply to author
Forward
0 new messages