[jboss-user] [JBoss jBPM] - Transactions on session facade in front of jBPM api

mauroarc do-not-reply at jboss.com
Thu Apr 12 09:14:11 EDT 2007


Hi i have a session facade "addUser" to add users and memberships to JBPM db using IdentitySession api.
I want rollback transaction if some runtimexception occurs, but it doesn't work and data is persisted anyway.
I'm using datasource on jboss3.2.3 and i've configured hibernate to use that data source for its connections.

Maybe i'm missing somewhat, please help me.
Below the code:

public void addUser(HashMap params) {
		
			log.debug("Start addUser");
			
		    IdentitySession identitySession = Util.getIdentitySession();
		   
		    User user = new User( (String)params.get("userName"));
		    user.setEmail( (String)params.get("email"));
			user.setPassword((String)params.get("userPwd"));
			
			String[] userGroupIds= (String[])params.get("userGroups");
			
			if ( userGroupIds!=null) {
			
			    long groupId=0;

			    for (int i=0; i<userGroupIds.length;i++) {

			    	groupId = Long.parseLong( userGroupIds);
				
			    	addMembership(user,groupId,identitySession);
			    }	
			}

		    identitySession.saveUser(user);
		    identitySession.getSession().flush();
		    
		  
		    log.debug("End addUser");
		}
		

		private void addMembership( User user, long groupId, IdentitySession identitySession) {
			Group group = identitySession.loadGroup(groupId);
				
			Membership membership = Membership.create(user,user.getName()+"_"+group.getId(), group);
			
			user.addMembership(membership);
			
			/*to simulate exception for testing*/
			if (true) {
				throw new RuntimeException("Error membership add");
			}
		
		}		

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

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



More information about the jboss-user mailing list