ISessionFactoryHolder Question.

29 views
Skip to first unread message

Cesar Sanz

unread,
Aug 24, 2011, 9:50:28 AM8/24/11
to Castle Project Users
Hello,

I have an application that is using the ISessionFactoryHolder to build
and get the sessionfactory.
The problem is that when executing this, I get multiples
SessionFactories which degrade the performance.
Why is that?
BTW I see this "Testing hock only." in the summary of the
ISessionFactoryHolder class.. What it means?

Thanks in advance

Jason Meckley

unread,
Aug 24, 2011, 12:21:37 PM8/24/11
to castle-pro...@googlegroups.com
I don't know where the ISessionFactoryHolder interface or implementation is, but the session factory should be a singleton. whether you manage this through an IOC or your own code you effectively want

static readonly ISessionFactory factory = new Configuration().Configure().BuildSessionFactory();

Cesar Sanz

unread,
Aug 24, 2011, 2:49:38 PM8/24/11
to Castle Project Users
Hi Jason,

Thanks for responding.... That is exactly what I want.. just one
instance of the ISessionFactory
The code I am using is

ISessionFactoryHolder holder = GetSessionFactoryHolder();
IStatelessSession session =

holder.GetConfiguration(holder.GetRootType(targetType)).BuildSessionFactory().OpenStatelessSession();

Using the ActiveRecordMediator.

English is my second language so I dont fully understand what "Testing
hock only" means
Can you explain me this sentence?

Jason Meckley

unread,
Aug 24, 2011, 3:13:24 PM8/24/11
to castle-pro...@googlegroups.com
sounds funny to me and English is my first language :)
I would assume they mean ISessionFactoryHolder is designed for testing only. for example: creating a session factory for each test.

Cesar Sanz

unread,
Aug 24, 2011, 3:59:58 PM8/24/11
to Castle Project Users
Well, it seems it was all my fault, I tried this:

IStatelessSession session =

holder.GetSessionFactory(holder.GetRootType(targetType)).OpenStatelessSession();

And now it works!! It now creates just one instance of teh
sessionfactory for the life of the application..

Thanks
Reply all
Reply to author
Forward
0 new messages