Can I get a reference to Configuration if I have reference to SessionFactory?

1 view
Skip to first unread message

epitka

unread,
Nov 20, 2009, 7:34:10 PM11/20/09
to nhusers
I need to get reference to Configuration to run ExportSchema. Is it
possible to get it from SessionFactory?

Diego Mijelshon

unread,
Nov 20, 2009, 9:16:29 PM11/20/09
to nhu...@googlegroups.com
I don't think so... in fact, I believe the SessionFactory doesn't even keep a direct reference to the Configuration (if it did, you could get it via reflection).

   Diego


On Fri, Nov 20, 2009 at 21:34, epitka <exptra...@yahoo.com> wrote:
I need to get reference to Configuration to run ExportSchema. Is it
possible to get it from SessionFactory?

--

You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=.



Fabio Maulo

unread,
Nov 20, 2009, 9:20:33 PM11/20/09
to nhu...@googlegroups.com
curiosity:
how you have the sessionFactory ?

2009/11/20 epitka <exptra...@yahoo.com>
I need to get reference to Configuration to run ExportSchema. Is it
possible to get it from SessionFactory?
--

You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=.





--
Fabio Maulo

epitka

unread,
Nov 21, 2009, 5:31:01 AM11/21/09
to nhusers
I use StructureMap with FluentNHibernate to set it up. Thought I could
get it from SessionFactory without having to re-write it so that I
hold on to reference to the Configuration in container.

ForRequestedType<ISessionFactory>()
.CacheBy(InstanceScope.Singleton)
.AddInstances(x => x.ConstructedBy(() =>
//
ObjectFactory.GetInstance<FluentConfiguration>()
Fluently.Configure()
.Database
(MsSqlConfiguration.MsSql2005
.AdoNetBatchSize(10)
.Driver
("NHibernate.Driver.SqlClientDriver")
.ProxyFactoryFactory
("NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle")
.UseOuterJoin()
.ConnectionString(@"Server=.
\SQLEXPRESS;User Id=epitka;Password=password;Database=dnn49;")
.ShowSql()
.CurrentSessionContext
("thread_static")) // CHANGE THIS FOR WEB
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<MetaProject>())
.ExposeConfiguration(
cfg =>{

cfg.SetProperty(

Environment.TransactionStrategy,

typeof (AdoNetTransactionFactory).FullName);

cfg.SetProperty(Environment.GenerateStatistics, "true"); //REMOVE FOR
LIVE
})

.BuildSessionFactory())
.WithName
("SharpMod_SessionFactory"));

On Nov 20, 8:20 pm, Fabio Maulo <fabioma...@gmail.com> wrote:
> curiosity:
> how you have the sessionFactory ?
>
> 2009/11/20 epitka <exptrade2...@yahoo.com>
>
>
>
>
>
> > I need to get reference to Configuration to run ExportSchema. Is it
> > possible to get it from SessionFactory?
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to nhu...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > nhusers+u...@googlegroups.com<nhusers%2Bunsu...@googlegroups.com >
> > .

epitka

unread,
Nov 21, 2009, 6:57:54 AM11/21/09
to nhusers
Ok, if anybody happens to use NHibernate with StructureMap and
FluentNHibernate here is how I did it:

http://stackoverflow.com/questions/1774145/nhibernate-configuration-reference-at-runtime/1775290#1775290

Fabio Maulo

unread,
Nov 21, 2009, 8:02:45 AM11/21/09
to nhu...@googlegroups.com
only for schema actions you can use directly the NH's config file (setting the property hbm2ddl.auto) and NH will do what you have configured in the rigth moment.



2009/11/21 epitka <exptra...@yahoo.com>
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/nhusers?hl=.





--
Fabio Maulo

epitka

unread,
Nov 21, 2009, 8:43:04 AM11/21/09
to nhusers
Not directly related but very cool, and actually came in the right
moment, as I had some props. that had names that needed to be quoted.
Many thanks.

On Nov 21, 7:02 am, Fabio Maulo <fabioma...@gmail.com> wrote:
> only for schema actions you can use directly the NH's config file (setting
> the property hbm2ddl.auto) and NH will do what you have configured in the
> rigth moment.http://fabiomaulo.blogspot.com/2009/06/auto-quote-tablecolumn-names.html
>
> <http://fabiomaulo.blogspot.com/2009/06/auto-quote-tablecolumn-names.html>
>
> 2009/11/21 epitka <exptrade2...@yahoo.com>
>
>
>
>
>
> > Ok, if anybody happens to use NHibernate with StructureMap and
> > FluentNHibernate here is how I did it:
>
> >http://stackoverflow.com/questions/1774145/nhibernate-configuration-r...
> > <nhusers%2Bunsu...@googlegroups.com<nhusers%252Bunsubscribe@googlegroup s.com>>

Fabio Maulo

unread,
Nov 21, 2009, 9:38:19 AM11/21/09
to nhu...@googlegroups.com
You have read only a part.... take your time and read it again... that post is related to SchemaExport too

2009/11/21 epitka <exptra...@yahoo.com>
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/nhusers?hl=.





--
Fabio Maulo
Reply all
Reply to author
Forward
0 new messages