4 Replies Latest reply on Jan 7, 2009 2:53 PM by Lisovoy Sergey

    Factory method and entity merge()

    Lisovoy Sergey Newbie

      I have folowing code:


      @Stateful
      @Name("orderManager")
      @Scope(ScopeType.CONVERSATION)
      public class OrderManagerBean implements OrderManager {
              @In("entityManager")
              private EntityManager em;
      
              @In
              private User currentUser;
      
              @RequestParameter
              private String id;
      
              ... 
      
              @Factory("selectedOrder")
              public void selectOrder() throws AccessDeniedException {
                      try {
                              Long orderId = Long.parseLong(this.id);
                              this.selectedOrder = this.em.createQuery(...).setParameter("id", orderId)
                                              .setParameter("user", this.currentUser)
                                              .getSingleResult(); 
                              
                      ...
                      // NOT WORKING CODE
                      this.selectedOrder.setIsVisited(true);
                      this.em.merge(this.selectedOrder);
              
                      ...
                      }
              ...
      



      Updating Order entity in factory method does not work. I look into log files. Nothing happens when called merge() method. Whats wrong?


      PS. I use JBoss 4.2.3GA, Seam 2.1.1.GA


      Thanks in advance.