6 Replies Latest reply on Dec 14, 2007 1:20 PM by Ivan B

    Fundamental question about em.persist

    Ivan B Novice

      Hi,

      Is there any functional difference between these two snippets (note the order of the last two statements)? When I look at the DB tables in the first case the name of the Card is null. Why so? I was dead sure any changes made to persistent object are flushed at the end of the transaction, so those two examples should give the same result. Everything is as expected in the second, the name of the Card is set properly.

      Can anyone comment on this?
      Thanks,

      @Name("initDBBean")
      @Scope(ScopeType.APPLICATION)
      public class InitDBBean {
       @Create
       @Transactional
       public void init() {
       Card card = new Card();
       entityManager.persist(card);
       card.setName("cardname");
       }
       }
      }
      


      @Name("initDBBean")
      @Scope(ScopeType.APPLICATION)
      public class InitDBBean {
       @Create
       @Transactional
       public void init() {
       Card card = new Card();
       card.setName("cardname");
       entityManager.persist(card);
       }
       }
      }