You shouldn't need to do the HbmMappings part, as that will be picked up
from your config.

On Sun, Mar 1, 2009 at 7:55 PM, epitka <exptrade2...@yahoo.com> wrote:

>
> That is the thing, NHibernateHelper is external to my assembly and has
> no reference to it, so I cannot us <MetaProject> as it does not know
> where the mappings are. Currently in .config file I have <mapping>
> attribute that tells it  from what assembly to load mappings. It would
> be nice if fnh could read <mapping> tab and check for fnh mapping
> classes.
> I guess I'll have to do something like this, where actual name of the
> assembly will have to be read from somewhere.
>
>   _sessionFactory = Fluently.Configure(cfg)
>                    .Mappings(m=> m.FluentMappings.AddFromAssembly
> (Assembly.Load("dnnSphere.Meta")))
>                    .Mappings(m=> m.HbmMappings.AddFromAssembly
> (Assembly.Load("dnnSphere.Meta")))
>                    .BuildSessionFactory();
>
> On Mar 1, 1:21 pm, James Gregory <jagregory....@gmail.com> wrote:
> > Yeah, that makes sense.
> > Your exception tells me that you haven't added any fluent mappings. You
> > should just be able to use the code from your first email combined with
> the
> > second.
> >
> > var cfg = LoadDefaultConfiguration();
> >
> > Fluently.Configure(cfg)
> >   .Mappings(m =>
> >     m.AddFromAssemblyOf<MetaProject>())
> >   .BuildSessionFactory();
> >
> > On Sun, Mar 1, 2009 at 7:04 PM, epitka <exptrade2...@yahoo.com> wrote:
> >
> > > I am trying to load regular nhibernate.config file that has
> > > connection, dialect, maping attribute and event listeners defined, and
> > > then use fluent to load mappings defined using fnh.
> > > Does that make sense?
> >
> > > On Mar 1, 12:30 pm, James Gregory <jagregory....@gmail.com> wrote:
> > > > I'm a little confused as to what you're trying to achieve. Can you
> > > explain
> > > > your setup a little better?
> >
> > > > On Sun, Mar 1, 2009 at 5:44 PM, epitka <exptrade2...@yahoo.com>
> wrote:
> >
> > > > > Here is the full stack
> >
> > > > > [MappingException: An association from the table dnnSphere_Package
> > > > > refers to an unmapped class: dnnSphere.Meta.Model.MetaProject]
> > > > >   NHibernate.Cfg.Configuration.LogAndThrow(Exception exception)
> +107
> > > > >   NHibernate.Cfg.Configuration.SecondPassCompileForeignKeys(Table
> > > > > table, ISet done) +642
> > > > >   NHibernate.Cfg.Configuration.SecondPassCompile() +797
> > > > >   NHibernate.Cfg.Configuration.BuildSessionFactory() +174
> > > > >   FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
> +162
> >
> > > > > [FluentConfigurationException: 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.
> > > > >  * No mappings were configured through the Mappings method.
> > > > > ]
> > > > >   FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
> +191
> > > > >   dnnSphere.NHibernate.NHibernateHelper.InitSessionFactory() +94
> >
> > > > > [Exception: NHibernate initialization failed]
> > > > >   dnnSphere.NHibernate.NHibernateHelper.InitSessionFactory() +178
> > > > >   dnnSphere.NHibernate.NHibernateHelper..ctor() +54
> > > > >   dnnSphere.NHibernate.NHibernateHelper..cctor() +39
> >
> > > > > [TypeInitializationException: The type initializer for
> > > > > 'dnnSphere.NHibernate.NHibernateHelper' threw an exception.]
> > > > >   dnnSphere.NHibernate.NHibernateHelper.get_Instance() +0
> >
> > >
> dnnSphere.NHibernate.HttpModules.SessionPerRequestModule.Application_BeginR
> > > equest
> > > > > (Object sender, EventArgs e) +37
> >
> > >
> System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep
> > > .Execute
> > > > > () +68
> > > > >   System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
> > > > > Boolean& completedSynchronously) +75
> >
> > > > > On Mar 1, 11:31 am, James Gregory <jagregory....@gmail.com> wrote:
> > > > > > That should work. Have you tested your config without Fluent?
> >
> > > > > > On 3/1/09, epitka <exptrade2...@yahoo.com> wrote:
> >
> > > > > > > Ok I can do it like this
> >
> > > > > > >   Configuration cfg = LoadDefaultConfiguration();
> > > > > > >                 _sessionFactory = Fluently.Configure
> > > > > > > (cfg).BuildSessionFactory();
> >
> > > > > > > but how do I add mapping assembly. Any ideas? nhibernate.config
> has
> > > > > > > mapping tag but is does not seem to work.
> >
> > > > > > > On Mar 1, 8:38 am, epitka <exptrade2...@yahoo.com> wrote:
> > > > > > >> hi,
> > > > > > >> Is there a way to load nhibernate.config directly through
> fluent?
> > > I
> > > > > > >> have a common assembly that I use for all NH project that
> deals
> > > with
> > > > > > >> sessions, config etc. Now I would like to be able to map
> entities
> > > > > > >> using Fluent but configure using normal nhibernate.config.
> Why?
> > > Well
> > > > > > >> for one in this line for example I don't know the assembly
> name,
> > > it is
> > > > > > >> specified in nhibernate.config.
> > > > > > >> .Mappings(m =>
> > > > > > >>       m.FluentMappings.AddFromAssemblyOf<Program>())
> >
>

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

Reply via email to