[jboss-jira] [JBoss JIRA] Commented: (EJBTHREE-1171) DDL in NativeQuery error rollbacks only Entity changes leaves nativequery executes committed

Guillermo Guisado (JIRA) jira-events at lists.jboss.org
Thu Jan 17 11:01:24 EST 2008


    [ http://jira.jboss.com/jira/browse/EJBTHREE-1171?page=comments#action_12395514 ] 
            
Guillermo Guisado commented on EJBTHREE-1171:
---------------------------------------------

Full Code:
CASE 1
@Stateless
@Local(UserSession.class)
@Remote(UserSession.class)
public class UserSessionBean implements UserSession{

	@PersistenceContext(unitName=GlobalConstants.persistenceContext)
	protected EntityManager myEntityManager;
	
	public void create(String userId, String userPassword) throws Exception {
		try{
			User user = new User(userId); 
			myEntityManager.persist(user); 
			String insertUserInOldTable = "insert into olduserstable values('" + userId + "')"; 
			myEntityManager.createNativeQuery(insertUserInOldTable ).executeUpdate(); 
			String userCreate = "CREATE USER " + userId + " IDENTIFIED BY " + userPassword + " DEFAULT TABLESPACE TB1 TEMPORARY TABLESPACE TEMPORARY PROFILE P1"; 
			// let say this fails because a user exists or the password does not conform the security measures
			myEntityManager.createNativeQuery(userCreate).executeUpdate(); 

		}
		catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}


@Stateless
@Local(UserSession.class)
@Remote(UserSession.class)
public class UserSessionBean implements UserSession{

	@PersistenceContext(unitName=GlobalConstants.persistenceContext)
	protected EntityManager myEntityManager;
	
	public vpid create(String userId, String userPassword) throws Exception {
		try{
			User user = new User(userId); 
			myEntityManager.persist(user); 
			String insertUserInOldTable = "insert into olduserstable values('" + userId + "')"; 
			myEntityManager.createNativeQuery(insertUserInOldTable ).executeUpdate(); 
			String userCreate = "dummy sql to fail";   
			myEntityManager.createNativeQuery(userCreate).executeUpdate(); 

		}
		catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}

> DDL in NativeQuery error rollbacks only Entity changes leaves nativequery executes committed
> --------------------------------------------------------------------------------------------
>
>                 Key: EJBTHREE-1171
>                 URL: http://jira.jboss.com/jira/browse/EJBTHREE-1171
>             Project: EJB 3.0
>          Issue Type: Bug
>    Affects Versions: AS 4.2.1.GA
>         Environment: Windows XP Sp2, Oracle 10.2.0.2.0
>            Reporter: Guillermo Guisado
>
> If the following code of a Stateless Session bean fails in the 5th line, the statement in the 3rd line does not rollback
> 0 User user = new User(userId);
> 1 myEntityManager.persist(user);
> 2 String insertUserInOldTable = "insert into olduserstable values('" + userId + "'); 
> 3 myEntityManager.createNativeQuery(insertUserInOldTable ).executeUpdate();
> 4 String userCreate = "CREATE USER " + userId + " IDENTIFIED BY " + userPassword + " DEFAULT TABLESPACE TB1 TEMPORARY TABLESPACE TEMPORARY PROFILE P1"; // let say this fails because a user exists or the password does not conform the security measures
> 5 myEntityManager.createNativeQuery(userCreate).executeUpdate();	 
> If the failing code is not DDL the 3rd line does rollback normally
> 0 User user = new User(userId);
> 1 myEntityManager.persist(user);
> 2 String insertUserInOldTable = "insert into olduserstable values('" + userId + "'); 
> 3 myEntityManager.createNativeQuery(insertUserInOldTable ).executeUpdate();
> 4 String userCreate = "dummy sql to fail";
> 5 myEntityManager.createNativeQuery(userCreate).executeUpdate();	 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list