[jboss-user] [JBoss Seam] - Need help with propagation of seam managed persistence conte
elikyip
do-not-reply at jboss.com
Mon Feb 26 14:19:19 EST 2007
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
More information about the jboss-user
mailing list