This content has been marked as final.
Show 2 replies
-
1. Re: EntityManagers in Application-scoped Startup components
samdoyle Feb 23, 2010 10:44 PM (in response to vinitadhopia)If you do that on startup you will block the application server from starting up until completed which I'm pretty sure you don't want to do.
What you can do is make your indexPerson @Asynchronous then from another component you can use @Observer or in your components.xml event for
org.jboss.seam.postInitialization then call your method.
Your entityManager should be injected successfully at that point. -
2. Re: EntityManagers in Application-scoped Startup components
vinitadhopia Feb 23, 2010 11:14 PM (in response to vinitadhopia)That did it! Thanks for the tip. For anyone curious, here's the working code:
@Name("personSearchInit") @Scope(ScopeType.APPLICATION) public class PersonSearchInit { @In private FullTextEntityManager entityManager; @Asynchronous @Observer("org.jboss.seam.postInitialization") public void indexPerson() { final List<Person> people = entityManager.createQuery("SELECT p FROM Person p").getResultList(); for (Person p : people) { entityManager.index(p); } } }