[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Will the container restore the transaction isolation level?

Marcos_APS do-not-reply at jboss.com
Mon Jan 19 06:32:14 EST 2009


Hello, everybody!

Look at the following code:


  | public void foo()
  | {
  |     Connection connection = null;
  |     PreparedStatement command = null;
  |     ResultSet data = null;
  |     try
  |     {
  |         InitialContext context = new InitialContext();
  |         DataSource dataSource =
  |             (DataSource) context.lookup("java:/BibliotecaDS");
  |         connection = dataSource.getConnection();
  |         connection.setTransactionIsolation(
  |             Connection.TRANSACTION_REPEATABLE_READ);
  | 
  |         // Execute some selects and updates...
  |     }
  |     catch (NamingException ex)
  |     {
  |         // Handle exception...
  |     }
  |     catch (SQLException ex)
  |     {
  |         // Handle exception...
  |     }
  |     finally
  |     {
  |         // Close resources...
  |     }
  | }
  | 
As you can see I'm getting a managed connection from the connection pool and changing its transation isolation level before using the connection to create statements and result sets. My doubt is: after the method completes and JBoss commit or rollback the updates, will the container revert the connection's transaction isolation level to the initial value, before the execution of the method? If so, that's what I expect and what
I want. If not, I won't be able to change the isolation level because suddenly I'll have a connection pool full of connections with a more restrictive isolation level, making my application run slow.

Thank you.

Marcos

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

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



More information about the jboss-user mailing list