1 Reply Latest reply on Nov 2, 2008 3:30 PM by João Bosco Monteiro

    Seam autosaves my entity

    Michał �ukasiewicz Newbie

      Hi,


      I'm experiencing some very odd JBoss Seam behaviour.


      On my view page I've got this form:



      <a:form>
      
          <h:inputText value="#{editWallet.editedWallet.name}"/>
          <a:commandButton
                  action="#{editWallet.selectWallet(walletItem)}"
                  value="save"
                  eventsQueue="commandQueue"
                  >
              <a:support event="onclick" eventsQueue="commandQueue"
                         action="#{editWallet.selectWallet(walletItem)}"/>
          </a:commandButton>
      
      </a:form>



      In fact I may have many of this form on a single page (each for different wallet object), thus just before submiting a form I must ensure that proper wallet object is selected - so I explicitly invoke method editWallet.selectWallet.


      Then - just for test - I've action parameter in commandButton set also to editWallet.selectWallet. And this make odd things happen!


      My stateful bean named editWallet is:


      @Stateful
      @Scope(ScopeType.SESSION)
      @Name("editWallet")
      public class EditWalletParametersAction implements EditWalletParameters {
      
          @PersistenceContext(type = PersistenceContextType.EXTENDED)
          private EntityManager entityManager;
      
          private Wallet editedWallet;
      
          public void selectWallet(Wallet wallet) {
              this.editedWallet = wallet;        
          }
      
      }



      When selectWallet method is invoked for the second time I can see in my JBoss log:


      10:45:31,296 INFO  [STDOUT] Hibernate:
          update
              Wallet
          set
              user_id=?,
              name=?,
              cash=?,
              createTime=?,
              visibleToOthers=?
          where
              id=?



      which means that entity is saved to db. But I do not want to save anything... And I do not invoke entityManager.merge(). So how can it be that the object is autosaved to db?