[jboss-user] [EJB 3.0] - Re: Transactions broken? Trivial Hibernate example with EJB3

smithmb do-not-reply at jboss.com
Wed Jan 16 16:14:48 EST 2008


Thank you for the reply -- setting relaxAutoCommit does not seem to work. Data is still committed immediately by the transaction manager, using the datasource I listed above PLUS relaxAutoCommit=true.

I even tried a very basic session bean method:

  | 	@TransactionAttribute(TransactionAttributeType.REQUIRED)
  | 	public void test()
  | 	{
  | 		
  | 		try {
  | 			javax.sql.DataSource ds = (javax.sql.DataSource) new InitialContext().lookup("java:/MySqlDS");
  | 			java.sql.Connection conn = ds.getConnection();
  | 			
  | 			System.out.println("IS AUTOCOMMIT: " + (conn.getAutoCommit()));
  | 			
  | 			Statement statement = conn.createStatement();
  | 			statement.execute("DELETE FROM BOOK");
  | 			statement.execute("INSERT INTO BOOK(title,author) VALUES(\"Should not see this title\",\"Should not see this author\")");
  | 			
  | 			
  | 			ctx.setRollbackOnly();
  | 			
  | 			statement.close();
  | 			conn.close();
  | 			
  | 		} catch (Exception ex) {
  | 			System.out.println(ex);
  | 		}
  | 	}
  | 

I *do* see the data that was inserted when it shouldn't have been. If, in that method above, I call conn.getAutoCommit(), it is set to false. I think the transaction manager is doing something wrong, but I have no way of investigating this further =/.

Please help!

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

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



More information about the jboss-user mailing list