4 Replies Latest reply on Oct 2, 2006 11:12 AM by Richard Leherpeur

    Populate pojoCache from Database at startup

    Richard Leherpeur Novice

      Hello,

      I created a component that is initialized at startup.
      This component is supposed to retrieve data from the database and store them in the pojoCache.

      The component is defined as:

      @Scope(ScopeType.APPLICATION)
      @Intercept(NEVER)
      @Startup(depends = {"pojoCache"})
      @Name("myComponent")
      public class MyComponent {
      
       privatePojoCache pojoCache = org.jboss.seam.core.PojoCache.instance();
      
       private EntityManager entityManager;
      
       @Create
       public void startup() throws Exception {
      
       // get data and store in the cache
       }
      }
      


      The entityManager that is also a component defined in the component.xml file as:

      <component name="entityManager"
      class="org.jboss.seam.core.ManagedPersistenceContext">
       <property name="persistenceUnitJndiName">java:/EntityManagerFactories/myDB</property>
      </component>
      


      To make sure the entityManager is loaded, I guess I need to add in the startup dependencies "entityManager", but then how do I get an instance of entityManager at this point?

      Injection is not working at startup.

      Thanks,

      Richard