Sai Stuff to Developers

October 1, 2013

Launched New Technology Site developersfusion.com

Hi Friends,

I have recently launched a new Technology WebSite www.developersfusion.com .

 

About Developers Fusion

Developers Fusion is a place where the professionals can share their experience and views contributing knowledge to the developer’s community. A successful professional, learns, explores, matures and finally contributes.

The developersfusion.com works with an idea, that has a big vision of bringing Technology to the cozy of your room wherever you are, and make learning comprehensive and exploring Technology real simple and easy.

We are dedicated in providing our Readers quality implementation, education, documentation and solutions. Our ultimate goal is to provide our readers with appropriate solution to their technical questions and needs. The developersfusion.com personifies the passion for Software Technology, delivers power in the technology and the skills associated with it, and enhances the productivity of professionals who shape the software field.

The developersfusion.com believes that it is vital to make learning Technology easy and effective and help its readers, technical breakthroughs in their future career along with other sessions that make them more informed about things that happen around them.

The Articles section lists articles published from different professionals enabling our readers to learn what’s new in the market and also the experience of the author. The FAQs section enables readers to prepare for answering the interview questions shot at them.

Our Vision

Bringing Technology to the cozy of every developer room wherever you are, and make learning comprehensive and exploring Technology real simple and easy.

Our Goal

Our ultimate goal is to provide our readers with appropriate solution to their technical questions and needs.

 

Hope all you make my new website a grand success by visiting posting and participating in forums etc…,

 

Regards,

Sai Kumar K

April 12, 2012

NHIBERNATE: ILLEGAL ATTEMPT TO ASSOCIATE A COLLECTION WITH TWO OPEN SESSIONS

Filed under: DotNet,NHibernate — tosaik @ 4:55 am
Tags: , ,

Hi All recently i got this issue when iam working on my application which is using NHibernate as the OR Mapper, and i seriously work around about this issue and got the tail of this issue.

This issue raised because i get an model object which had lazy load option true and modified the same object and trying to save/update the same object.. this is fine from our side but what accually happening inside the Nhibenate is due to lazy load the model object still running on a Nhibernate session, again when we say save the same object it created another session to save it as current context session is already running to fetch the model object.. so NHibernate doesnt accept an object running on two or more sessions.

Solution: Solution is simple we need to manage or code what ever the word.. try to have a single session always active..
for this we need to change a little coding as shown here.

private static ISession _mySession;

public static ISession mySession
        {
            get {
               
                if (!CurrentSessionContext.HasBind(SessionFactory))
                    CurrentSessionContext.Bind(SessionFactory.OpenSession());
                
                _mySession = SessionFactory.GetCurrentSession();
                return _mySession;
            }
        }

Here in the above couple of lines of code says to the NHibernate that if any session is aready bind to the Current Context then use the same session and if not create one session and bind the same to the Current Context.

Hope this Helps you….

Happy Coding 🙂

 

Create a free website or blog at WordPress.com.

%d bloggers like this: