Illegal attempt to associate a collection with two open sessions

4 views
Skip to first unread message

Nieve

unread,
Dec 7, 2008, 12:00:08 PM12/7/08
to nhusers
Hello all,
new to the list, hope I'll be able to contribute as well :)
Before I begin, here's a bit of background: I'm working on a library
cataloguing application using NHibernate + Spring.Net (the latest
versions for both) strictly for educational reasons...

The exception I've mentioned is thrown whenever attempting to do a
session.SaveOrUpdate() on an object (library Item) containing a many-
to-many property (IList<LibTransaction> Transactions). The mapping
(using NHibernate.Mapping.Attributes) looks like this:

[Bag(0, Access = "property", Lazy = true, Inverse = true, Name =
"Transactions", Table = "ItemTransaction")]
[Key(1, Column = "ItemID")]
[ManyToMany(2, ClassType = typeof(LibTransaction), Column =
"TransactionID")]
public virtual IList<LibTransaction> Transactions
{
get { return transactions; }
set { transactions = value; }

}

The exception is also thrown whenever attempting
IPersistentCollection.SetCurrentSession() with the above mentioned
property.

It should be noted that the exception is thrown only after the
Transactions property is lazily initialised.

session management as well as transactions are being taken care of by
the spring HibernateDaoSupport class and the spring transaction
attributes respectively.

I would be grateful for any idea or response!

Nieve

unread,
Dec 10, 2008, 4:33:21 PM12/10/08
to nhusers
Just in case anyone with a similar issue will come up with this
thread- the answer can be found on the spring forum:
http://forum.springframework.net/showthread.php?t=5218
Reply all
Reply to author
Forward
0 new messages