Yeah, same problem here with user supplied connection. When building session factory NH tries to query db for keywords, but fails cause can't create connection. I wounder what to do, I must provide connection myself, but I need to quote identifiers.
On Wednesday, June 13, 2012 1:24:24 PM UTC+4, Reto Ghioldi wrote: > > Hi all > > Guess I found a bug in NHibernate....but maybe I'm just using it wrong. > > I use SQL Server 2008 R2 with NHibernate 3.3.0.GA with a > UserSuppliedConnectionProvider (property "connection.provider") because I > want to use the <connectionStrings> section of the normal application > configuration. > > Is it correct, that I can use the UserSuppliedConnectionProvider property > only with the property "hbm2ddl.keywords" set to "none"? > > Will say: > ===== > <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> > <session-factory> > <property > name="dialect">NHibernate.Dialect.MsSql2008Dialect</property> > <property > name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> > <property > name="connection.provider">NHibernate.Connection.UserSuppliedConnectionProvider</property> > <property name="hbm2ddl.keywords">none</property> > ... > </session-factory> > </hibernate-configuration> > ===== > > Using the following values for "hbm2ddl.keywords" results in an exception: > "keywords", "auto-quote" > > The exception says: "The user must provide an ADO.NET connection - > NHibernate is not creating it." > It occurs when I call BuildSessionFactory() on the NHibernate > Configuration. The user supplied connection would be passed to the > OpenSession() method of the ISessionFactory which happens later. > So, it's just not possible to pass in the user supplied connection because > the factory can never be built. This seems very odd to me and makes no > sense. So, I guess this is a bug. Right? > > StackTrace: > ==== > at NHibernate.Connection.UserSuppliedConnectionProvider.GetConnection() > in > c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Connection\UserSuppliedConnectionProvider.cs:line > > 46 > at > NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prepare() > in > c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Tool\hbm2ddl\SuppliedConnectionProviderConnectionHelper.cs:line > > 25 > at > NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect > dialect, IConnectionHelper connectionHelper) in > c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Tool\hbm2ddl\SchemaMetadataUpdater.cs:line > > 43 > at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory > sessionFactory) in > c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Tool\hbm2ddl\SchemaMetadataUpdater.cs:line > > 17 > at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping > mapping, Settings settings, EventListeners listeners) in > c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Impl\SessionFactoryImpl.cs:line > > 174 > at NHibernate.Cfg.Configuration.BuildSessionFactory() in > c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Cfg\Configuration.cs:line > > 1258 > at ... <myCode> :-) > ==== > > It would be great if I could also use the nice looking "hbm2ddl.keywords" > feature. > > For the feature see also: > > http://nhforge.org/blogs/nhibernate/archive/2009/06/24/auto-quote-table-column-names.aspx > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/groups/opt_out.
