quality@glassfish.java.net

RE: weird problem with items from entity

From: Vladimir Perlov <vladperl_at_hotmail.com>
Date: Thu, 19 Nov 2009 03:25:56 +0000

> This setItemList is a "normal" setter?
Yes, it is. See the code:
 
 public void setItemList(List<OrderItem> itemList) {
    this.itemList = itemList;
  }

I have suspicious the issue somehow linked to the fact that "Order" is persistence entity.
I attached couple related classes that could help with investigation.
In fact the same problem exists also for "PurchaseOrder" class not just "Order" but it's understandable because the code practically the same.

   public Order saveOrder(Order order) {
      List<OrderItem> list = order.getItemList();
      order.setItemList(null);
.............................................

   public PurchaseOrder savePurchaseOrder(PurchaseOrder purchaseOrder) {
      purchaseOrder.updateTotalAmount();
      List<PurchaseOrderItem> list = purchaseOrder.getItemList();
// Execution of the following statement suddenly modified variable "list"
      purchaseOrder.setItemList(null);

Maybe there is something wrong with how persistence context manage cache of the entities?
The issue appears only with already existing entities such as "order" where user just added additional item to already existing list of order items.

Please let me know what else you need to figure out the problem.

Thank you,
Vladimir
From: fgaucho_at_gmail.com
To: quality_at_glassfish.dev.java.net
Date: Wed, 18 Nov 2009 22:51:26 +0100
Subject: Re: weird problem with items from entity

This setItemList is a "normal" setter?

On 18.11.2009, at 22:45, Vladimir Perlov <vladperl_at_hotmail.com> wrote:


Hi everybody,
I have very strange issue that appears in all the last promoted builds of Glassfish v3.
At least on Glassfish Prelude I know my code is working fine.
I really don't know what part of the system responsible for it and beside it could be mayor bug that need to be fixed quickly.
At least in my application it's serious issue.

Description the issue:

   public Order saveOrder(Order order) {
      List<OrderItem> list = order.getItemList();
      order.setItemList(null);

Let's say the order's item list contains two items before running the method shown above.
"list" variable after assignment obviously also has two elements inside of the list. (first row in the method)
Then after statement "order.setItemList(null);" executed the variable list has suddenly only one item instead of expected two.

For more information I could say only that "Order" class is entity and the method "saveOrder" is located inside stateless enterprise java bean:

@Stateless
public class EntityController implements EntityControllerLocal {
--------------------------------------------------------------------------------

Of course the following work around working find but still I believe it should be fixed as soon as possible:

      List<OrderItem> list = new ArrayList<OrderItem>();
      list.addAll(order.getItemList());
      order.setItemList(null);


I don't have much time to prepare test case but If somebody need it I can send the whole application and even real DB to make it alive. There is no any sensitive data inside my DB.

Thank you,
Vladimir
                                               
Bing brings you maps, menus, and reviews organized in one place. Try it now.
                                               
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141665/direct/01/