Regular |
 |
Joined: Mon Aug 28, 2006 6:35 am Posts: 66 Location: Middle East
|
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:NHibernate v1.0.2
Mapping documents:
Development Environment: ASP.NET 2.0 (C#)
Name and version of the database you are using: SQL SERVER EXPRESS 2005
Dear members.
I'm having an exception while trying to save a MANY - TO - MANY relationship .. The classes are : Category and Item ...
I'm using IList with <bag> .
In the category facade class, i've implemented the SaveCollectionItem () method:
ArrayList itemlist = new ArrayList();
itemlist.Add(item);
cat.idcategoryiditems = itemlist;
mgr.saveItem(item);
Save(cat);
The saveItem is successfully saved but the Category saving is fainling and raising the following exception (the Category class is successfully saved apart but here tthe exception is raised) :
Illegal attempt to associate a collection with two open sessions Parameter name: Illegal attempt to associate a collection with two open sessions Actual value was NHibernate.HibernateException: Illegal attempt to associate a collection with two open sessions at NHibernate.Collection.PersistentCollection.SetCurrentSession(ISessionImplementor session) at NHibernate.Impl.OnUpdateVisitor.ProcessCollection(Object collection, PersistentCollectionType type) at NHibernate.Impl.AbstractVisitor.ProcessValue(Object value, IType type) at NHibernate.Impl.AbstractVisitor.ProcessValues(Object[] values, IType[] types) at NHibernate.Impl.AbstractVisitor.Process(Object obj, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdateMutable(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdate(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj) at nhExhibition.DataAccess.ExhibitionDBMgr.Save(Object item, Boolean pointlessParameter) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.DataAccess\ExhibitionDBMgr.cs:line 326. Parameter name: Illegal attempt to associate a collection with two open sessions Parameter name: Illegal attempt to associate a collection with two open sessions Actual value was NHibernate.HibernateException: Illegal attempt to associate a collection with two open sessions at NHibernate.Collection.PersistentCollection.SetCurrentSession(ISessionImplementor session) at NHibernate.Impl.OnUpdateVisitor.ProcessCollection(Object collection, PersistentCollectionType type) at NHibernate.Impl.AbstractVisitor.ProcessValue(Object value, IType type) at NHibernate.Impl.AbstractVisitor.ProcessValues(Object[] values, IType[] types) at NHibernate.Impl.AbstractVisitor.Process(Object obj, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdateMutable(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdate(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj) at nhExhibition.DataAccess.ExhibitionDBMgr.Save(Object item, Boolean pointlessParameter) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.DataAccess\ExhibitionDBMgr.cs:line 326. Actual value was System.ArgumentOutOfRangeException: Illegal attempt to associate a collection with two open sessions Parameter name: Illegal attempt to associate a collection with two open sessions Actual value was NHibernate.HibernateException: Illegal attempt to associate a collection with two open sessions at NHibernate.Collection.PersistentCollection.SetCurrentSession(ISessionImplementor session) at NHibernate.Impl.OnUpdateVisitor.ProcessCollection(Object collection, PersistentCollectionType type) at NHibernate.Impl.AbstractVisitor.ProcessValue(Object value, IType type) at NHibernate.Impl.AbstractVisitor.ProcessValues(Object[] values, IType[] types) at NHibernate.Impl.AbstractVisitor.Process(Object obj, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdateMutable(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdate(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj) at nhExhibition.DataAccess.ExhibitionDBMgr.Save(Object item, Boolean pointlessParameter) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.DataAccess\ExhibitionDBMgr.cs:line 326. at nhExhibition.DataAccess.ExhibitionDBMgr.Save(Object item, Boolean pointlessParameter) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.DataAccess\ExhibitionDBMgr.cs:line 335 at nhExhibition.DataAccess.ExhibitionDBMgr.Save(Object item) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.DataAccess\ExhibitionDBMgr.cs:line 310 at nhExhibition.BusinessFacade.CategoryFacade.Save(Category cat) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.BusinessFacade\CategoryFacade.cs:line 32 at nhExhibition.BusinessFacade.CategoryFacade.SaveCatItemsCollections(Category cat, Item item) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.BusinessFacade\CategoryFacade.cs:line 86. Parameter name: Illegal attempt to associate a collection with two open sessions Parameter name: Illegal attempt to associate a collection with two open sessions Actual value was NHibernate.HibernateException: Illegal attempt to associate a collection with two open sessions at NHibernate.Collection.PersistentCollection.SetCurrentSession(ISessionImplementor session) at NHibernate.Impl.OnUpdateVisitor.ProcessCollection(Object collection, PersistentCollectionType type) at NHibernate.Impl.AbstractVisitor.ProcessValue(Object value, IType type) at NHibernate.Impl.AbstractVisitor.ProcessValues(Object[] values, IType[] types) at NHibernate.Impl.AbstractVisitor.Process(Object obj, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdateMutable(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdate(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj) at nhExhibition.DataAccess.ExhibitionDBMgr.Save(Object item, Boolean pointlessParameter) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.DataAccess\ExhibitionDBMgr.cs:line 326. Parameter name: Illegal attempt to associate a collection with two open sessions Parameter name: Illegal attempt to associate a collection with two open sessions Actual value was NHibernate.HibernateException: Illegal attempt to associate a collection with two open sessions at NHibernate.Collection.PersistentCollection.SetCurrentSession(ISessionImplementor session) at NHibernate.Impl.OnUpdateVisitor.ProcessCollection(Object collection, PersistentCollectionType type) at NHibernate.Impl.AbstractVisitor.ProcessValue(Object value, IType type) at NHibernate.Impl.AbstractVisitor.ProcessValues(Object[] values, IType[] types) at NHibernate.Impl.AbstractVisitor.Process(Object obj, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdateMutable(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdate(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj) at nhExhibition.DataAccess.ExhibitionDBMgr.Save(Object item, Boolean pointlessParameter) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.DataAccess\ExhibitionDBMgr.cs:line 326. Actual value was System.ArgumentOutOfRangeException: Illegal attempt to associate a collection with two open sessions Parameter name: Illegal attempt to associate a collection with two open sessions Actual value was NHibernate.HibernateException: Illegal attempt to associate a collection with two open sessions at NHibernate.Collection.PersistentCollection.SetCurrentSession(ISessionImplementor session) at NHibernate.Impl.OnUpdateVisitor.ProcessCollection(Object collection, PersistentCollectionType type) at NHibernate.Impl.AbstractVisitor.ProcessValue(Object value, IType type) at NHibernate.Impl.AbstractVisitor.ProcessValues(Object[] values, IType[] types) at NHibernate.Impl.AbstractVisitor.Process(Object obj, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdateMutable(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdate(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj) at nhExhibition.DataAccess.ExhibitionDBMgr.Save(Object item, Boolean pointlessParameter) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.DataAccess\ExhibitionDBMgr.cs:line 326. at nhExhibition.DataAccess.ExhibitionDBMgr.Save(Object item, Boolean pointlessParameter) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.DataAccess\ExhibitionDBMgr.cs:line 335 at nhExhibition.DataAccess.ExhibitionDBMgr.Save(Object item) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.DataAccess\ExhibitionDBMgr.cs:line 310 at nhExhibition.BusinessFacade.CategoryFacade.Save(Category cat) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.BusinessFacade\CategoryFacade.cs:line 32 at nhExhibition.BusinessFacade.CategoryFacade.SaveCatItemsCollections(Category cat, Item item) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.BusinessFacade\CategoryFacade.cs:line 86. Actual value was System.ArgumentOutOfRangeException: Illegal attempt to associate a collection with two open sessions Parameter name: Illegal attempt to associate a collection with two open sessions Actual value was NHibernate.HibernateException: Illegal attempt to associate a collection with two open sessions at NHibernate.Collection.PersistentCollection.SetCurrentSession(ISessionImplementor session) at NHibernate.Impl.OnUpdateVisitor.ProcessCollection(Object collection, PersistentCollectionType type) at NHibernate.Impl.AbstractVisitor.ProcessValue(Object value, IType type) at NHibernate.Impl.AbstractVisitor.ProcessValues(Object[] values, IType[] types) at NHibernate.Impl.AbstractVisitor.Process(Object obj, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdateMutable(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdate(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj) at nhExhibition.DataAccess.ExhibitionDBMgr.Save(Object item, Boolean pointlessParameter) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.DataAccess\ExhibitionDBMgr.cs:line 326. Parameter name: Illegal attempt to associate a collection with two open sessions Parameter name: Illegal attempt to associate a collection with two open sessions Actual value was NHibernate.HibernateException: Illegal attempt to associate a collection with two open sessions at NHibernate.Collection.PersistentCollection.SetCurrentSession(ISessionImplementor session) at NHibernate.Impl.OnUpdateVisitor.ProcessCollection(Object collection, PersistentCollectionType type) at NHibernate.Impl.AbstractVisitor.ProcessValue(Object value, IType type) at NHibernate.Impl.AbstractVisitor.ProcessValues(Object[] values, IType[] types) at NHibernate.Impl.AbstractVisitor.Process(Object obj, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdateMutable(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdate(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj) at nhExhibition.DataAccess.ExhibitionDBMgr.Save(Object item, Boolean pointlessParameter) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.DataAccess\ExhibitionDBMgr.cs:line 326. Actual value was System.ArgumentOutOfRangeException: Illegal attempt to associate a collection with two open sessions Parameter name: Illegal attempt to associate a collection with two open sessions Actual value was NHibernate.HibernateException: Illegal attempt to associate a collection with two open sessions at NHibernate.Collection.PersistentCollection.SetCurrentSession(ISessionImplementor session) at NHibernate.Impl.OnUpdateVisitor.ProcessCollection(Object collection, PersistentCollectionType type) at NHibernate.Impl.AbstractVisitor.ProcessValue(Object value, IType type) at NHibernate.Impl.AbstractVisitor.ProcessValues(Object[] values, IType[] types) at NHibernate.Impl.AbstractVisitor.Process(Object obj, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdateMutable(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.DoUpdate(Object obj, Object id, IClassPersister persister) at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj) at nhExhibition.DataAccess.ExhibitionDBMgr.Save(Object item, Boolean pointlessParameter) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.DataAccess\ExhibitionDBMgr.cs:line 326. at nhExhibition.DataAccess.ExhibitionDBMgr.Save(Object item, Boolean pointlessParameter) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.DataAccess\ExhibitionDBMgr.cs:line 335 at nhExhibition.DataAccess.ExhibitionDBMgr.Save(Object item) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.DataAccess\ExhibitionDBMgr.cs:line 310 at nhExhibition.BusinessFacade.CategoryFacade.Save(Category cat) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.BusinessFacade\CategoryFacade.cs:line 32 at nhExhibition.BusinessFacade.CategoryFacade.SaveCatItemsCollections(Category cat, Item item) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.BusinessFacade\CategoryFacade.cs:line 86. at nhExhibition.BusinessFacade.CategoryFacade.SaveCatItemsCollections(Category cat, Item item) in C:\Documents and Settings\bacem\My Documents\Visual Studio 2005\Projects\Exhibition 03\nhExhibition.BusinessFacade\CategoryFacade.cs:line 93 at AddItems.DoSave() in c:\Exhibition 03\AddItems.aspx.cs:line 128 at AddItems.button_save_Click(Object sender, EventArgs e) in c:\Exhibition 03\AddItems.aspx.cs:line 136.
Regards,
Jojorico
_________________ In Code We Trust
|
|