2 Replies Latest reply on Jul 18, 2008 2:15 PM by Dean Hiller

    LazyInit Exception vs. db tx not working?

    Dean Hiller Expert

      I was following the hotel example and have something like this...

           public void editPosition(EmployerPosition pos) {
                this.employerPosition = mgr.merge(pos);
                occupation = employerPosition.getFixedPosition().getOccupation();
                category = occupation.getOccupationCategory();
                state = employerPosition.getMajorCity().getState();

      but if I do that, every time I change a field, it changes the employerPosition object and the db tx commits for some reason!!!!  I am very confused why it is being committed to the database.  I started a long transaction and don't want changes committed if the user cancels out of the conversation.  this is a 3 step wizard and the user should be able to cancel but right now all changes are written immediately.  Why is this happening?  If I don't do the mgr.merge(though the hotel booking does that too), it then results in LazyInit exception on the next line.  Any ideas on how to solve this problem?

      I wish there was a great seam example of creating a new something and editing that same something with the same exact code which is what I am trying to do...convert the new wizard into an edit wizard as well.