[jboss-user] [JBoss Seam] - Re: Can't inject entityManager into application component?
RobJellinghaus
do-not-reply at jboss.com
Fri Aug 25 18:16:11 EDT 2006
That's a nice stab at an explanation, but it can't be the whole story. Here's a session-scoped component that's been working just fine in my application for months now:
@Name("replogSession")
| @Startup
| @Scope(SESSION)
| public class ReplogSession {
| ...
| @In(create=true)
| private transient EntityManager entityManager;
|
| @In
| private Replog replogApplication; // local interface of the stateful session bean above
|
| ...
| public Changeset createChangeset (String description) {
| ...
| Query query = entityManager.createQuery("from RepObject ro where ro.replicatedChangeset is null and " +
| "not exists (from RepObject ro2 where ro2.replicatedChangeset is not null " +
| "and ro2.version = ro.version and ro2.replicatedKey = ro.replicatedKey)");
| List<RepObject> list = query.getResultList();
| ...
| }
That's a plain old session-scoped POJO that has an EntityManager injected into it with @In. Works just great! I've never needed to use @PersistenceContext anywhere else in my app. And I have an EntityManager Seam component in my resources/WEB-INF/components.xml:
<component name="entityManager" class="org.jboss.seam.core.ManagedPersistenceContext">
| <property name="persistenceUnitJndiName">java:/entityManagerFactory</property>
| </component>
So why doesn't Seam's application scope support injecting that EntityManager with @In, when Seam's session scope does support it?
Cheers!
Rob
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3967588#3967588
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3967588
More information about the jboss-user
mailing list