So when i am saving a voyage everything goes well however when i added a <set name="dailyCargo" inverse="true" order-by="REP_NO"> <key column="LINEUP_NO"></key> <one-to-many class="DailyCargo"/> </set> it started giving me this exception
org.springframework.orm.hibernate3.HibernateSystemException: Illegal attempt to associate a collection with two open sessions; nested exception is org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
Can you post your code and also mappings of the related class too, and also use the CODE button below to put your mappings and code in between those two tags so that your formatting of indentations remain, without indentation the stuff is very hard to read.
In your code, do you have two Sessions open? If so, close the first one before starting the second.
In your related class mapping, I am assuming you have the inverse Many-To-One, correct?
I haven't read the code yet, but I saw this at the end of your post
"Is this something to do with transactions"
The relationship between Session and Transactions is one to one. You cannot start and commit a transaction, then try to create another one within the same Session session (meaning open and close).
OK, so then is Spring creating the Session and Transactions for you. I am sorry but I have not used Spring, so I am not familiar with how the Spring/Hibernate combination works.
The problem was with the OSIV filter mapping. I had given singleSession as false so it was creating a session on get* and another on save*. I changed it to true and alls well
Originally posted by nelson christos: Thanks for your reply Mark
The problem was with the OSIV filter mapping. I had given singleSession as false so it was creating a session on get* and another on save*. I changed it to true and alls well