How to Solve NHibernate entity association issue?

Asked By 0 points N/A Posted on -
qa-featured

I am having issues with NHibernate. I have got a few methods in DAL and I use Session Factory.

When I run this application it  runs perfectly alright, but there are sometimes it throws in an exception saying Entity <Entity Name> is already associated with entity ID <Number>.

I am looking for ways to solve this issue; any idea?

 

 

SHARE
Answered By 0 points N/A #92822

How to Solve NHibernate entity association issue?

qa-featured

Hi Nadeemrao!

NHibernates have different sessions of which session factory is one of them.

These errors usually occur when you are creating a new entity on every database call and sometimes using old ones.

If you are using Poco entities, the frequency of this issue will be reduced to 10% and get the session object for poco entity in each method.

To resolve the method completely I am suggesting a method that worked for me: I cleared the session on every database call and in this way, everything worked for me.

Although am not sure if it will work for you, you can give it a trial.

 

 

Login/Register to Answer

Related Questions