no-EJB deployment, seam managed sessions and commit/flush ti
andrew.rw.robinson Jan 18, 2006 1:16 AMI saw a similar conversation to my question (http://www.jboss.com/index.html?module=bb&op=viewtopic&t=72052), but it didn't cover exactly what I was looking for and was hoping someone could clarify how to accomplish the following. First my setup:
Tomcat 5.5
Hibernate 3.1
SeamExtendedManagedPersistencePhaseListener
Okay, what I want to do (I'll just mention tihs one example):
Administrator goes to a page for editing web site users
Admin picks a user to edit
Admin changes first name
Admin chooses to add a new address to the user (address is a mapped child object in hbm.xml)
Admin enters address data
Admin clicks save or cancel
Result:
User table is not changed until save is clicked and user & address objects are validated (user is not updated when the "add address" action is processed/fired and the page is re-rendered)
If admin clicks the cancel, all changes are thrown out (rollback)
During this time, I'd rather not have a database lock, so the user can still log in an change their own profile (while the administrator is working on their profile).
Now, I couldn't be sure from the post mentioned above how to stop the session being flushed during the "add address" action processing. Also, I am not sure when to being the hibernate transaction (when the user starts to edit the user, when the add address is called, or only in the save action).
What is the best way to handle this in Seam without using EJB3 support? Is there a way to do this that "works" with the hibernate session, or should I evict the user from the session, and explicitly call session.update()?
Example code:
@Scope(ScopeType.CONVERSATION) @Name("userAdmin") @Conversational(ifNotBegunOutcome("listUsers")) public class UserAdmin implements Serializable { ... @In(create=false, value="userList") @Out(value="userList", required=false, scope=ScopeType.CONVERSATION) private List<User> users; @In(create=false, value="editingUser") @Out(value="editingUser", required=false) @Valid private User user; @In(create=true) private Session database; @Begin public String selectUser() {...} @End public String cancel() {...} @End @IfInvalid(outcome=REDISPLAY) public String save() {...} public String addAddress() {...}
Thanks, Andrew