I never figured out the answer to this question; but I was able to solve my 
problem. SQL Server's connection string has the Connection Timeout 
property, and whoever wrote this code originally accidentally set it to 
10000, probably thinking milliseconds, but it's seconds, so about 2.78 hrs; 
which is why it appeared to be waiting indefinitely.

On Monday, September 4, 2023 at 1:09:24 PM UTC-6 Tomas Ramirez wrote:

> Hello, I'm super new to Fluent NHibernate, and ORMs in general; so maybe 
> assume I don't know anything :D
>
> How do I configure c3p0 checkoutTimeout, in Fluent NHibernate?
>
> The app appears to be hanging when the DB server is offline, when it tries 
> to run BuildSessionFactory. It sounds like I need to configure c3p0's 
> checkoutTimeout, or else it will wait forever for the DB connection (
> https://forum.hibernate.org/viewtopic.php?p=2426663).
>
> I failed to find any examples, and it looks like c3p0 has its own 
> <c3p0-config> element, when you do it the XML way; so I'm not sure how I'm 
> supposed to do that with Fluent NHibernate (
> https://webcache.googleusercontent.com/search?q=cache:ujHcueltIzoJ:https://www.appsloveworld.com/oracle/100/66/how-to-configure-c3p0-in-hibernate-to-auto-refresh-stale-db-connections&cd=11&hl=en&ct=clnk&gl=us
> ).
>
> Here's what the code looks like:
>
> _sessionFactory = Fluently.Configure()
> .Database(MsSqlConfiguration.MsSql2012
>     .ConnectionString(GetConnectionString())
>     .AdoNetBatchSize(22)
>     .UseReflectionOptimizer())
>     .Mappings(m => DatabaseHelper.BaseDbMappingsInMainDb.ForEach(db => m.
> FluentMappings.Add(db)))
> .ExposeConfiguration(config =>
> {
>     config.SetProperty("prepare_sql", "true");
>     config.SetProperty("command_timeout", "30");
>     config.SetProperty("default_flush_mode", "Commit"); // default: 
> Unspecified
> })
> .BuildSessionFactory();
>
> So, I can see how I would normaly set properties; but since 
> checkoutTimeout is a property under the nested <c3p0-config> element (which 
> seems to be nested under the normal config element), I doubt it's going to 
> work if I just try to configure it directly.
>
> (I am about to start experimenting with the code; but this is a weird 
> little sub-app that runs within an installer; so it's not trivially easy 
> for me to test this code out, at the moment.)
>
> Many thanks.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fluent-nhibernate+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fluent-nhibernate/78f2cd10-305f-4cf2-bdc8-8708cddd9880n%40googlegroups.com.

Reply via email to