[jboss-user] [JBoss Seam] - Re: TransactionRequiredException

lightbulb432 do-not-reply at jboss.com
Wed Jan 3 09:53:34 EST 2007


Below is the first class where somebody simply logs in with the login() method.

@Stateless
  | @Name("login")
  | public class LoginBean implements Login {
  | 
  |     @PersistenceContext(type=TRANSACTION) 
  |     private EntityManager em;
  | 
  |     @Out(required=false)
  |     private Member member;
  | 
  |     public String login() {
  | 		
  |        member = new MemberGetter(em).getMember(loginName);
  | 
  |        if (member.getPassword().equals(getPassword())) {
  |            return "good";
  |        }
  |        else {
  |            return null;
  |        }
  | 
  |       ...
  | 
  | }


Once they are logged in, let's say they need to add a new name. The problem is that when you add a new name I don't think Member gets injected into the stateful bean from the outjected stateless login() method...

Does it have anything to do with the transaction attributes, persistence context types, or the fact that I'm going from stateless to stateful calls in one conversation?


@Stateful
  | @Name("change")
  | public class ChangeBean implements Change {
  | 
  |     @PersistenceContext(type=EXTENDED)
  |     private EntityManager em;
  | 
  |     @In(create=true) @Out(required=false)
  |     private Member member;
  | 
  |     public String addName() {
  | 		
  |     if (!new ChangeName(em).nameExists(name)) {
  |         member.getNames().add(name);
  |         return "good";
  |     }
  |     else {
  |         return null;
  |     }
  | 
  |     ...
  | 		
  | }

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3997570#3997570

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3997570



More information about the jboss-user mailing list