4 Replies Latest reply on Jun 18, 2006 2:15 AM by Tim McCune

    Can't get database updated without calling flush()

    Tim McCune Novice

      I'm writing my first Seam component to update a persistent entity. Here's the code:

      @Stateless
      @Scope(ScopeType.EVENT)
      @Name("accountEditor")
      public class AccountEditorBean implements AccountEditor {
      
       @In(required=false)
       private AccountManager accountManager;
      
       @Valid
       private Account account;
      
       @In(create=true)
       private Session session;
      
       public String select() {
       account = accountManager.getSelectedAccountSummary().getAccount();
       return "editAccount";
       }
      
       @IfInvalid(outcome=Outcome.REDISPLAY, refreshEntities=true)
       public String update() {
       session.update(account);
       // NOTE: Without this line uncommented, no database update occurs!
       //session.flush();
       return "home";
       }
      
       public Account getAccount() {
       return account;
       }
      }


      Note the commented-out line. When I have the flush() commented out, no database updates are happening to account. When I manually flush in the update() method, the database updates occur as I would expect. Surely, it's not intended that I have to manually flush every time I want to update something. Am I just missing something painfully obvious?

      I am using Seam 1.0, JBoss 4.0.4, and Hibernate 3.2cr1. I am using the SeamExtendedManagedPersistencePhaseListener.

      Any suggestions would be appreciated.