2 Replies Latest reply on May 12, 2008 5:59 PM by Pete Muir

    Is using an entityManager during postInitialization bad form?

    John Gilbert Apprentice

      I am trying to do some database initialization during postInitialization but I am getting a 'No Transaction' exception. There is nothing useful in the log.


      Am I missing something, or should I avoid doing this?



      @Name("myInit")
      @Scope(ScopeType.APPLICATION)
      public class MyInit {
      
           @In
           private EntityManager entityManager;
      
           @Observer("org.jboss.seam.postInitialization")
           @Transactional
           public void init() throws Exception {
                MyEntity e = new MyEntity();
                ...
                entityManager.merge(e);
           }
      }