Cant see my new data after ejb 3.0 Facade.create()

I am adding an address using EJB 3.0 Facade.create() method. On a separate page I call another EJB 3.0 customer.getAddressCollection() method, but the collection of addresses still has the old list. It does not have the new address in there.If I log out and back in it still does not show the new address. Only when I start another session can I see the new address.

I am using Sun App Server version 9.0.

Is there some App Server setting or some "flush" or "commit" method I am overlooking?

Here is the relevant code:

// update the database using the Facade EJB

addressFacade.create(address);

customerMaintenanceMessage ="finished adding address";

request.setAttribute("activity","mainPage");

request.setAttribute("customerMaintenanceMessage",customerMaintenanceMessage);

RequestDispatcher disp = getServletContext().getRequestDispatcher("/CustomerMaintenance");

disp.forward(request, response);

//forward to the addressList page:

Customer thisCustomer = customerFacade.find(customerId);

List<Address> addresses = (List)thisCustomer.getAddressCollection();

request.setAttribute("addresses",addresses);

disp = getServletContext().getRequestDispatcher("/AddressList.jsp");

disp.forward(request, response);

// Address List display JSP

List<Address> addresses = (List) request.getAttribute("addresses");

for (Address address : addresses){

//display the address...

}

[1926 byte] By [Perryiera] at [2007-11-26 19:27:35]
# 1

I was able to get a working solution I added the following code right below the addressFacade.create(address) line in the update the database section:

customer.getAddressCollection().add(newAddress);

customerFacade.edit(customer);

Essentially, I had to update the address, the customer addressCollection, AND update the customer entity.

I think this is cumbersome, but maybe it is the price paid for the simplicity of EJB 3.0.

Perryiera at 2007-7-9 21:54:12 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...