openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From is_maximum <mnr...@gmail.com>
Subject Re: EntityManager dosn't release connection in XA transactions
Date Wed, 23 Dec 2009 05:51:50 GMT

FYI, we have monitored our connection pool, when using DataSource the
NumConnDestroyed is increased after each statement execution but using
EntityManager the NumConnDestroyed is always 0 

here is the snippet code and more details:


Datasource Classname: oracle.jdbc.xa.client.OracleXADataSource
Resource Type: javax.sql.XADataSource

Oracle Version: 10.2.0.1.0
Oracle JDBC Driver Version: 10.2.0.1.0
Glassfish: 9.1_02 (build b04-fcs)
OpenJPA: 1.2.1


@Resource(name="jdbc/myDS", type=javax.sql.DataSource.class)
private DataSource dataSource;

@WebMethod(operationName="addAccount")
      @TransactionAttribute(TransactionAttributeType.REQUIRED)
      public String addAccount(){
            String accountCode;
            String sql = "INSERT INTO ACCOUNT …";
            Connection connection = null;
            Statement statement = null;
            try{
                  
                  connection = dataSource.getConnection();
                  
                  statement = connection.createStatement();
                  statement.executeUpdate(sql);
                  
                  
            }catch(SQLException exception){
                  //…
            }
            
return accountCode;
      }

      
@PersistenceContext(unitName="pu-cm")
      protected EntityManager entityManager;

@WebMethod(operationName="addAccount")
      @TransactionAttribute(TransactionAttributeType.REQUIRED)
      public String addAccount(){
            String accountCode;
            Account account =  new Account();

            account.setAmount(10.0);
            //…

            entityManager.persist(account);
            entityManager.flush();
            
            return accountCode;
      }


-----
--
Regards
Mohammad
http://pixelshot.wordpress.com Pixelshot 
-- 
View this message in context: http://n2.nabble.com/EntityManager-dosn-t-release-connection-in-XA-transactions-tp4205041p4207379.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message