[JBoss Seam] - Need help with propagation of seam managed persistence conte
by elikyip
Hi
I'm a newbie to seam and ejb3 and need some help regarding Persistence Context (PC) propagation.
I have the code snippets below using @EJB and @PersistenceContext(type=EXTENDED) that properly propagate the PC to my EJB DAO.
However, when I changed @EJB to seam @In injection for my DAO and EntityManager it seems like the PC is no longer propagated.
Can someone tell what I'm doing wrong? Please let me know if you need more detail.
Any suggestion is appreciated.
========= REMOTE Stateful Bean using @EJB and PC properly propagated ===========
@Stateful
@Name("userService")
public class UserEJBService implements UserService {
@EJB
private UserDAO _userDAO;
@PersistenceContext(type=EXTENDED)
private EntityManager _em;
public User test(Long userId) {
User user =_em.find(User.class, userId);
boolean contain = _userDAO.contains(user); // PC properly progagated and "contain" == true
return user;
}
}
========= REMOTE Stateful Bean using @In and PC NOT propagated ===========
@Stateful
@Name("userService")
public class UserEJBService implements UserService {
@In(value="userDAO", create=true)
private UserDAO _userDAO;
@In(value="entityManager")
private EntityManager _em;
public User test(Long userId) {
User user =_em.find(User.class, userId);
boolean contain = _userDAO.contains(user); // PC NOT progagated and "contain" == false
return user;
}
}
========= LOCAL Stateless DAO Bean ===========
@JndiName("jboss-seam-booking/UserDAOBean/local")
@Stateless
@TransactionAttribute(TransactionAttributeType.REQUIRED)
@Name("userDAO")
public class UserDAOBean extends GenericEJBDAO<User, Long>
implements UserDAO {
public boolean contains(User user) {
return getEntityManager().contains(user);
}
}
========= components.xml ===========
<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://jboss.com/products/seam/components"
xmlns:core="http://jboss.com/products/seam/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.1.xsd
http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.1.xsd">
<core:init jndi-pattern="jboss-seam-booking/#{ejbName}/remote" debug="true"/>
<core:pages no-conversation-view-id="/main.xhtml"/>
<core:manager conversation-timeout="120000"
concurrent-request-timeout="500"
conversation-id-parameter="cid"
conversation-is-long-running-parameter="clr"/>
<core:ejb installed="@embeddedEjb@"/>
<core:managed-persistence-context name="entityManager"
auto-create="true"
persistence-unit-jndi-name="java:/SFEntityManagerFactory"/>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4022630#4022630
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4022630
19Â years, 1Â month
[JBoss Seam] - Re: Begin conversation *before* entering a method
by schmatz
"baz" wrote : BTW: when the user logs out (via identity.logout the session is invalidated and all Objects are removed.
Oh, I didn't know that identity.login starts a session and logout invalidates it.
"baz" wrote : Putting entitys in conversation scope is fully supported in Seam without the need to change the behaviour of the framework.
I know. You misunderstood me. I don't want to change the framework behavior.
"baz" wrote : When you want really the login within an conversation, start the conversation when you render the login page. (eg propagation="join").
I thought of that but know I think it's not the best idea I had... ;-)
"baz" wrote :
| Understanding conversations is one of the hard part of seam. But the docu about that becomes better and better and is now in a good state for easy understanding.
That's totally true! The big mistake on my side was that I didn't know that identity.login starts a session. Now things become clear to me....
Thank you for that,
Mark
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4022628#4022628
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4022628
19Â years, 1Â month