Sure. I can't do this via the BeanFactory (this is a standalone jar) so I've been doing it in code as either one of the following to wrap the DAO in transactions:

Configuration 1:

Code:

            Properties p = new Properties();
            p.setProperty("create*", "ISOLATION_REPEATABLE_READ");
            p.setProperty("update*", "ISOLATION_REPEATABLE_READ");
            p.setProperty("remove*", "ISOLATION_REPEATABLE_READ");
            p.setProperty("*", "PROPAGATION_REQUIRED,readOnly");

            TransactionProxyFactoryBean tpfb = new TransactionProxyFactoryBean();
            tpfb.setTransactionManager(new DataSourceTransactionManager(ds));
            tpfb.setTransactionAttributes(p);
            tpfb.setTarget(new DeploymentDaoIbatis(ds));
            tpfb.afterPropertiesSet();
            return (DeploymentDao) tpfb.getObject();


Configuration 2:

Code:

            Properties p = new Properties();
            p.setProperty("create*", "ISOLATION_REPEATABLE_READ");
            p.setProperty("update*", "ISOLATION_REPEATABLE_READ");
            p.setProperty("remove*", "ISOLATION_REPEATABLE_READ");
            p.setProperty("*", "PROPAGATION_REQUIRED,readOnly");

            ProxyFactory pf = new ProxyFactory();
            pf.addInterface(DeploymentDao.class);
            pf.setTarget(new DeploymentDaoIbatis(ds));

            TransactionInterceptor ti = new TransactionInterceptor();
            ti.setTransactionAttributes(p);
            ti.setTransactionManager(new DataSourceTransactionManager(ds));
            pf.addAdvisor(new TransactionAttributeSourceAdvisor(ti));
            return (DeploymentDao) pf.getProxy();


However, why do you think this has anything to do with the Spring transactions? From the Ibatis source code, it seems that calling:
SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(new
InputStreamReader(
leads to a txManager never being initted on SQLMapExecutorDelegate. Is there another call that I'm supposed to be making?

Thanks
Reuben


Geoff Chiang wrote:
Can you post your Spring configuration for the relevant beans?

Geoff

--- [EMAIL PROTECTED] wrote:

  
If I turn lazy loading on, it is throwing an NPE from one specific
sqlmaps
query. The other queries & inserts work correctly.

When I posted this problem last week, I misdirected attention by
theorizing that this had something to do with the fact that I'm using
spring transactions; I'm pretty sure it doesn't:

The stacktrace is:


    
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.endTransaction(SqlMapExecutorDelegate.java:776)
  
at

    
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.endTransaction(SqlMapSessionImpl.java:137)
  
at

    
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.endTransaction(SqlMapClientImpl.java:115)
  
at

    
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.autoEndTransaction(SqlMapExecutorDelegate.java:860)
  
at

    
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:617)
  
at

    
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:584)
  
at

    
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:101)
  
at

    
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:7Cool
  
at

    
com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.getResult(ResultLoader.java:72)
  
at

    
com.ibatis.sqlmap.engine.mapping.result.loader.LazyResultLoader.loadObject(LazyResultLoader.java:9Cool
  
at

    
com.ibatis.sqlmap.engine.mapping.result.loader.LazyResultLoader.invoke(LazyResultLoader.java:81)
  
at $Proxy1.toArray(Unknown Source)

At this point in the code, it is doing:

txManager.end(session);

txManager is, obviously, a TransactionManager; it is only built,
apparently, from the constructor of SqlMapConfigParser.


To initialize, I do, in the constructor of my class which extends
SqlMapClientDaoSupport:

        super.setDataSource(ds);
        SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(new
InputStreamReader(         

    
Config.getClasspathResource("classpath:.../ibatisSQLMapsConfig.xml").getInputStream()));
  
        super.setSqlMapClient(smc);


SqlMapClientBuilder.buildSqlMapClient(...)

calls:

  return new SqlMapConfigParser().parse(reader);

The constructor with no arguments is as follows:

  public SqlMapConfigParser() {
    this(null, null);
  }

However, line 272 of SqlMapConfigParser is never reached:

  vars.client.getDelegate().setTxManager(txManager);

In fact, the process(Node node) method that it is wrapped in is never
invoked; I don't have the source for NodeletParser handy, so I can't
see
why it is failing. I can look into this further if this problem is
not
reproducible by the devs.

Am I missing something from my setup, or this a bug in Ibatis?

Thanks




    



		
____________________________________________________ 
Do you Yahoo!? 
The New Yahoo! Movies: Check out the Latest Trailers, Premiere Photos and full Actor Database. 
http://au.movies.yahoo.com


  

Reply via email to