0 Replies Latest reply on Jul 18, 2008 10:06 PM by nthompson.nate.cimconsultants.com

    How to get EntityManager from Schedulable?

    nthompson.nate.cimconsultants.com

      Greetings.


      I'm trying to implement a nightly job via the org.jboss.varia.scheduler.Scheduler mbean that requires access to the database.  I'm unsure about the correct way to obtain a reference to the database/EntityManager.


      If I try


              EntityManagerFactory emf = Persistence 
                    .createEntityManagerFactory("my-persistence-unit-name");
              this.em = emf.createEntityManager();
      


      I get errors about there not being a transaction...


      What is the correct way to do this?


      Thanks,


      Nate