Sounds like a plan. If you do manage to get it working, just show us what you did and we'll be able to translate it into fluent for you :)
On Wed, Aug 5, 2009 at 9:21 PM, ComradeF <[email protected]> wrote: > > You're right, so I started playing with vanilla NH to figure out what > they might be talking about with this single Session Factory business. > Haven't got it yet, and this leaves me wondering if it's going to be > possible at all... the documentation seems to indicate that it is. > I'll let you know if I manage to configure NHibernate without an > initial connection. > > > On Aug 5, 3:14 pm, James Gregory <[email protected]> wrote: > > Check the InnerException, I imagine it's from NHibernate. The Database > was > > not configured bit is just a suggestion as to why you might have got an > > exception. > > > > On Wed, Aug 5, 2009 at 9:07 PM, ComradeF <[email protected]> wrote: > > > > > Are you sure I don't have to specify a connection? > > > > > If I call Fluently.Configure() with .Mappings() > > > and .BuildSessionFactory() but not .Database(), I get this exception: > > > > > An invalid or incomplete configuration was used while creating a > > > SessionFactory. Check PotentialReasons collection, and InnerException > > > for more detail. > > > > > * Database was not configured through Database method. > > > > > On Aug 5, 2:24 pm, James Gregory <[email protected]> wrote: > > > > You don't have to specify a database connection, but I'm not sure how > > > you'd > > > > construct the session factory without it. I'm pretty sure NHibernate > > > itself > > > > doesn't like it. > > > > > > On Wed, Aug 5, 2009 at 8:22 PM, ComradeF <[email protected]> wrote: > > > > > > > This post evolved from another thread that started out asking a > > > > > completely different question, but it evolved to this... so here's > a > > > > > new thread. > > > > > > > From the NHibernate documentation: > > > > > > > -------------------------------------------------------------- > > > > > 3.2. Obtaining an ISessionFactory > > > > > > > When all mappings have been parsed by the Configuration, the > > > > > application must obtain a factory for ISession instances. This > factory > > > > > is intended to be shared by all application threads: > > > > > > > ISessionFactory sessions = cfg.BuildSessionFactory(); > > > > > > > However, NHibernate does allow your application to instantiate more > > > > > than one ISessionFactory. This is useful if you are using more than > > > > > one database. > > > > > > > 3.3. User provided ADO.NET connection > > > > > > > An ISessionFactory may open an ISession on a user-provided ADO.NET > > > > > connection. This design choice frees the application to obtain > ADO.NET > > > > > connections wherever it pleases: > > > > > > > IDbConnection conn = myApp.GetOpenConnection(); > > > > > ISession session = sessions.OpenSession(conn); > > > > > > > // do some data access work > > > > > > > The application must be careful not to open two concurrent > ISessions > > > > > on the same ADO.NET connection! > > > > > > > 3.4. NHibernate provided ADO.NET connection > > > > > > > Alternatively, you can have the ISessionFactory open connections > for > > > > > you. The ISessionFactory must be provided with ADO.NET connection > > > > > properties in one of the following ways: > > > > > > > 1. Pass an instance of IDictionary mapping property names to > > > > > property values to Configuration.SetProperties(). > > > > > 2. Add the properties to a configuration section in the > application > > > > > configuration file. The section should be named nhibernate and its > > > > > handler set to System.Configuration.NameValueSectionHandler. > > > > > 3. Include <property> elements in a configuration section in the > > > > > application configuration file. The section should be named > hibernate- > > > > > configuration and its handler set to > > > > > NHibernate.Cfg.ConfigurationSectionHandler. The XML namespace of > the > > > > > section should be set to urn:nhibernate-configuration-2.0. > > > > > 4. Include <property> elements in hibernate.cfg.xml (discussed > > > > > later). > > > > > > > If you take this approach, opening an ISession is as simple as: > > > > > > > ISession session = sessions.OpenSession(); // open a new Session > > > > > // do some data access work, an ADO.NET connection will be used on > > > > > demand > > > > > -------------------------------------------------------------- > > > > > > > I'd like to use the option described in 3.3 (manage my own > connections > > > > > so I don't have to keep making new Session Factories), but to call > > > > > Fluently.Configure() at all, I've got to provide a database > connection > > > > > -- leading me to believe that FNH is forcing the option described > in > > > > > 3.4 (NHibernate receives connection information and then uses it > from > > > > > that point on such that OpenSession() is handled for me). > > > > > > > Is there a way for me to do this such that I don't have to create a > > > > > Session Factory each time I want to start a dialogue with a > database? > > > > > In other words, can I Fluently.Configure() without database > connection > > > > > information, and just handle the connections on-the-fly per > Session? > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---
