I have an ASP.NET web application using NHibernate 1.0.1.0 running on IIS with MS SQL Server 2000 on the back end.
The application basically consists of a wizard-style interface that allows users to enter information over several pages. This information gets stored in one main object (BuildingPlan) that has a few one-to-one relationships and one-to-many relationships.
Since the UI spans several pages, I don't retrieve and update in the same Hibernate session. On the first page, the BuildingPlan is retrieved and put in the http session just as the user is forwarded to the next page:
BuildingPlan plan = mgr.RetrieveBuildingPlan("someplanid000"); Session["CurrentPlan"] = plan; Response.Redirect("plan_submit_01.aspx");
After each page (I've only completed the first 2 so far), the information gets updated (or it should be anyway :) ). Now, entering info for a new plan works fine, and retrieving that info works. The problem is, when I bring up a previously entered plan, make changes, and then try to submit changes, the info in the database does not get updated. There are no errors and things look like they're working, but the changes are not persisted.
The following is the method the next page calls to submit changes to the various objects that are passed in with an IList (an ArrayList in this case).
private void StoreIList(IList list) { ISession session = factory.OpenSession(); ITransaction transaction = session.BeginTransaction(); for (int i = 0; i < list.Count; i++) { session.SaveOrUpdate(list[i]); }
transaction.Commit();
session.Flush(); session.Close(); }
The other thing that is interesting is that if I create an object, store it, retrieve it in a seperate session, make changes, and then update it all in the code-behind then it DOES work. So my guess is that something about using the BuildingPlan object with ASP.NET server controls and/or storing the plan in session is interfering with something.
Any guesses or feedback? I'm sure it's probably something trivial I'm missing. I'm relatively new to ASP.NET.
|