You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Eric Tan <er...@yahoo.com.sg> on 2006/07/10 11:05:31 UTC

Isolation level support at the DAO framework level ...

Hi

Since 2.0.9, the SQL Maps framework has the ability to specify isolation level per transaction, eg: 
 
 sqlMap.startTransaction(Connection.TRANSACTION_REPEATABLE_READ); 
 
 However, using the DAO framework, there is still no way to specify an isolation level using DaoManager.startTransaction(). 
 
 Just wondering, were there any previous considerations why isolation level support wasn't added to the DaoManager back in 2.0.9? 
 
 Thanks         
                -->
      
 		
---------------------------------

 The World Cup Is Now On Your Favorite Front Page - check out www.yahoo.com.sg

Re: Isolation level support at the DAO framework level ...

Posted by Eric Tan <er...@yahoo.com.sg>.
Hi Jeff

Thanks for the reply.

I had suspected that it would be hard to implement this for all the different frameworks.

I like the idea of being able to demarcate transactions above the DAO level. For example, in the JPetStore example, within the OrderService.java, the transaction involves 2 DAOs.

  public void insertOrder(Order order) {
    try {
      // Get the next id within a separate transaction
      order.setOrderId(getNextId("ordernum"));

      daoManager.startTransaction();

      itemDao.updateAllQuantitiesFromOrder(order);
      orderDao.insertOrder(order);

      daoManager.commitTransaction();
    } finally {
      daoManager.endTransaction();
    }
  }

For each DAO in the JPetStore, there is no need to demarcate transactions. It is done at the Service object level. This is both clean and simple and provides more reuse of DAO methods when a new service is required and must work within its own transaction. 

I had used iBatis for a project back in 2003 and I love it for its simplicity. Back then I was using only the SQL Map. 

This time round, I decided to try out the DAO framework, together with SQL Map. I anticipated the need to set isolation level for certain requirements, hence the JIRA ticket and this thread.

I think this request will only complicate things, so I guess I will fall back to using SQL Map with transaction demarcation shifted to within the DAO classes.

For example,

class MyDAO {

    public void insertOrder(...) {
        sqlMap.startTransaction(Connection.TRANSACTION_SERIALIZABLE);
        sqlMap.update("Item.updateInventoryQuatity", ...);
        sqlMap.insert("Order.insertOrder", ...)'
        sqlMap.commitTransaction();
    .....
    .....
    }
}

Thanks,
Eric





Jeff Butler <je...@gmail.com> wrote: I don't know why it wasn't done in the 2.0.9 time frame, but I've been looking at it due to your JIRA ticket.  The truth is that this isn't that easy to do.  The DAO framework supports DAOs for iBATIS SqlMaps, Hibernate, Toplink, OJB, etc.  It is not so easy to set the isolation level programmatically in all of these implementations.  Most of the implementations have other ways to set this - typically in some configuration setting. 
  
 If we add a method to the DaoManager interface to set isolation level, someone would have to figure out how to do it programmatically in all the other frameworks - either that or throw a bunch of UnsupportedOperationExceptions. 
  
 If you could describe what you're trying to achieve then maybe we could help you find a way to do it.
  
 Jeff Butler
 

 
 On 7/10/06, Eric Tan <er...@yahoo.com.sg> wrote:  Hi

Since 2.0.9, the SQL Maps framework has the ability to specify isolation level per transaction, eg: 

sqlMap.startTransaction(Connection.TRANSACTION_REPEATABLE_READ); 

However, using the DAO framework, there is still no way to specify an isolation level using  DaoManager.startTransaction(). 

Just wondering, were there any previous considerations why isolation level support wasn't added to the DaoManager back in 2.0.9? 

Thanks 
 
 
  

---------------------------------
 
The World Cup Is Now On Your Favorite Front Page - check out  www.yahoo.com.sg  




 

 		
---------------------------------
 
 Real people. Real questions. Real answers. Share what you know.

Re: Isolation level support at the DAO framework level ...

Posted by Jeff Butler <je...@gmail.com>.
I don't know why it wasn't done in the 2.0.9 time frame, but I've been
looking at it due to your JIRA ticket.  The truth is that this isn't that
easy to do.  The DAO framework supports DAOs for iBATIS SqlMaps, Hibernate,
Toplink, OJB, etc.  It is not so easy to set the isolation level
programmatically in all of these implementations.  Most of the
implementations have other ways to set this - typically in some
configuration setting.

If we add a method to the DaoManager interface to set isolation level,
someone would have to figure out how to do it programmatically in all the
other frameworks - either that or throw a bunch of
UnsupportedOperationExceptions.

If you could describe what you're trying to achieve then maybe we could help
you find a way to do it.

Jeff Butler



On 7/10/06, Eric Tan <er...@yahoo.com.sg> wrote:
>
> Hi
>
> Since 2.0.9, the SQL Maps framework has the ability to specify isolation
> level per transaction, eg:
>
> sqlMap.startTransaction(Connection.TRANSACTION_REPEATABLE_READ);
>
> However, using the DAO framework, there is still no way to specify an
> isolation level using DaoManager.startTransaction().
>
> Just wondering, were there any previous considerations why isolation level
> support wasn't added to the DaoManager back in 2.0.9?
>
> Thanks
>
>
>  ------------------------------
>
> The World Cup Is Now On Your Favorite Front Page - check out
> www.yahoo.com.sg<http://sg.rd.yahoo.com/mail/sg/footer/def/*http://sg.yahoo.com>
>
>