Environment: Tomcat 5.5 + Seam 2.1.0 + Microcontainer, Seam-managed 
transactions and PCs.

UserBean.java - displays a list of existing User records, allowing user to 
select one (a-la "clickable lists" example) and edit it, or to create a new 
record:
@Name ("userBean")
  | @Scope (ScopeType.CONVERSATION)
  | @Transactional
  | public class UserBean extends EntityController {
  |     @DataModelSelection
  |     @Out (required = false)
  |     private User selectedUser;
  |     @DataModel
  |     private List<User> users;
  | 
  |     public void addUser() {
  |             selectedUser = new User();
  |     }
  |     public void cancelEdit() {
  |             selectedUser = null;
  |     }
  |     @Factory ("users")
  |     @Begin (flushMode = FlushModeType.MANUAL)
  |     public void createRecords() {
  |             users = createQuery("SELECT u FROM User u").getResultList();
  |     }
  |     public void saveUser() {
  |             // getEntityManager().joinTransaction();
  |             persist(selectedUser);
  |             flush();
  |             addFacesMessage("User #{selectedUser.username} succesfully 
saved");
  |             createRecords();
  |     }
  |     public void selectUser() {
  |     }
  | }
  | 

When executing saveUser(), if selectedUser is a transient (new) instance, the 
flush() call throws a "javax.persistence.TransactionRequiredException: no 
transaction is in progress". If the first line is uncommented, the save 
completes successfully (verified in DB). When selectedUser is a managed 
(existing) instance, the updates complete successfully whether the first line 
is commented or not.

Is this a bug? Am I using the bean in a correct way?

Thanks,

Alex

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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4034230
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to