Announcement Announcement Module
Collapse
No announcement yet.
Another possible bug saving objects to hibernate in ConversationFlow Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Another possible bug saving objects to hibernate in ConversationFlow

    So I have been investigating this problem I reported here:
    http://forum.springframework.org/showthread.php?t=26820

    And I have narrowed it down to only happening when I am calling this saveOrder() method in a webflow's MultiAction class using an object from the conversationScope..

    What I did to test was this:
    * I copied in some simple test code for adding new orders into the system in a simple MVC controller and then created a simple Order object (with supporting model objects) and saved it in the controller. Everything worked fine.
    Code is as follows:
    Code:
    User u     = getAccountManager().getUser("testEmail");
            Address addr  = ((UserAddress) u.getUserAddresses().toArray()[0]).getAddress();
            CreditCard cc = (CreditCard) u.getCreditCards().toArray()[0];
            Store store   = new Store();
    
            store.setId(1);
    
            OrderStatus os = new OrderStatus();
    
            os.setId(1);
    
            Order o = new Order();
    
            o.setOrderStatus(os);
            o.setCreditCard(cc);
            o.setDeliveryAddress(addr);
            o.setTotalOrderTaxAmount(new BigDecimal(3));
            o.setTotalOrderQuantity((short) 3);
            o.setTotalOrderNetAmount(new BigDecimal(3));
            o.setStore(store);
            o.setRequestedDeliveryDate(VodoriUtils.getCurrentSQLTimestamp());
            o.setPreperationHoursRequired((short) 3);
            o.setUser(u);
            getCommerceManager().saveOrder(o);
    * Once I confirmed I can save an order in a simple MVC controller, I moved the test code into my MultiAction class which is where my "real" save is supposed to be happening
    * I then created a new order object from scratch, like above, and everything saves just fine, even in the MultiAction class I have extended... However, once I get the order from the conversationScope and then set all the values, I get the stack trace linked at the top of this post. The code to reproduce the problem in my MultiAction class is:

    Code:
    //DIFFERENCE IS THIS LINE:
    Order order = (Order) context.getConversationScope().get("order");
    
    
            User u     = getAccountManager().getUser("testEmail");
            Address addr  = ((UserAddress) u.getUserAddresses().toArray()[0]).getAddress();
            CreditCard cc = (CreditCard) u.getCreditCards().toArray()[0];
            Store store   = new Store();
    
            store.setId(1);
    
    //REMOVED THE NEW ORDER OBJECT HERE
    
            OrderStatus os = new OrderStatus();
    
            os.setId(1);
    
            order.setOrderStatus(os);
            order.setCreditCard(cc);
            order.setDeliveryAddress(addr);
            order.setTotalOrderTaxAmount(new BigDecimal(3));
            order.setTotalOrderQuantity((short) 3);
            order.setTotalOrderNetAmount(new BigDecimal(3));
            order.setStore(store);
            order.setRequestedDeliveryDate(VodoriUtils.getCurrentSQLTimestamp());
            order.setPreperationHoursRequired((short) 3);
            order.setUser(u);
            getCommerceManager().saveOrder(order);
    Note: The ONLY difference is that in the first case (which works) I am creating a new Order object from scratch where in the 2nd case (fails) I am grabbing an order object from the converationScope...

    Any help would be greatly appreciated!!

    Thanks

  • #2
    Well, I don't think the fact it's in conversation scope really is the problem. I'm curious who put the order in conversation scope, and was the order loaded by hibernate rather than created transiently?

    Keep in mind objects stored in conversation scope are maintained for the life of the conversation--and this means if they were loaded by Hibernate this could cause problems on subsequent requests if the instance was proxied (which according to the exception it is).

    Keith

    Comment


    • #3
      Keith, I found my problem and indeed it did not have to do with the conversation scope. I posted the problem and solution here:

      http://forum.springframework.org/sho...ed=1#post68727

      Turns out session scoped beans to not play nicely with Hibernate

      Comment

      Working...
      X