ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From TNO <tno...@free.fr>
Subject Re: lazy loader NPE
Date Sat, 15 Oct 2005 08:08:41 GMT
I think this is a Spring problem...
Use a transactionManager from Spring...
I use Ibatis and Spring and for the transaction, I do this :

  <bean id="myPropertyConfigurer" 
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
      <list>
        <value>arc/constante/jdbc.properties</value>
      </list>
    </property>
  </bean>
  <bean id="dataSourceArc" class="com.ibatis.common.jdbc.SimpleDataSource">
    <constructor-arg>
        <map>
            <entry key="JDBC.Driver" value="${jdbc.driverClassName}"/>
            <entry key="JDBC.ConnectionURL" value="${jdbc.url}"/>
            <entry key="JDBC.Username" value="${jdbc.username}"/>
            <entry key="JDBC.Password" value="${jdbc.password}"/>
            <entry key="JDBC.DefaultAutoCommit" value="true"/>
            <entry key="Pool.PingQuery" value="SELECT 1"/>
            <entry key="Pool.PingEnabled" value="true"/>
            <entry key="Pool.PingConnectionsOlderThan" value="1000000"/>
        </map>
    </constructor-arg>
  </bean>

  <bean id="transactionManagerArcService" 
class="org.springframework.jdbc.datasource.DataSourceTransactionManager" 
destroy-method="close">
    <property name="dataSource">
      <ref bean="dataSourceArc" />
    </property>
  </bean>
  <bean id="baseTransactionProxyArcService" 
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" 
abstract="true">
    <property name="transactionManager">
      <ref bean="transactionManagerArcService" />
    </property>
    <property name="transactionAttributes">
      <props>
        <prop key="save*">PROPAGATION_REQUIRED,-DataAccessException</prop>
        <prop key="delete*">PROPAGATION_REQUIRED,-DataAccessException</prop>
        <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
      </props>
    </property>
  </bean>

  <bean id="sqlMapClientArcDb" 
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    <property name="configLocation">
      <value>classpath:arc/db/config/sql-map-config-arcdb.xml</value>
    </property>
  </bean>

  <bean id="xxxDAO" class="arc.db.auto.dao.ibatis.xxxDAOiBatis" 
lazy-init="true">
    <property name="dataSource"><ref bean="dataSourceArc" /></property>
    <property name="sqlMapClient"><ref bean="sqlMapClientArcDb" 
/></property>
  </bean>

  <bean id="xxxMgr" parent="baseTransactionProxyArcService" 
lazy-init="true">
    <property name="target">
      <bean class="arc.db.service.impl.xxxMgrImpl" autowire="byName">
        <property name="xxxDAO"><ref bean="xxxDAO" /></property>
      </bean>
    </property>
  </bean>


reubenf@sonic.net a écrit :

>I found one reference to this:
>
>http://www.google.com/search?q=cache:y2UKgchz25IJ:mail-archives.apache.org/mod_mbox/incubator-ibatis-user-java/200502.mbox/%253C16178eb10502262030d30d080%40mail.gmail.com%253E+at+com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.endTransaction(SqlMapExecutorDelegate.java:776)&hl=en
>
>According to the solution, I should add a TransactionManager to my sqlmap.
>I haven't yet tried, but how does this play with Spring's transactions? My
>transactions are currently setup via Spring's AOP framework:
>
>            ProxyFactory pf = new ProxyFactory();
>            pf.addInterface(DeploymentDao.class);
>            pf.setTarget(new DeploymentDaoIbatis(ds));
>            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");
>            TransactionInterceptor ti = new TransactionInterceptor();
>            ti.setTransactionAttributes(p);
>            ti.setTransactionManager(new DataSourceTransactionManager(ds));
>            pf.addAdvisor(new TransactionAttributeSourceAdvisor(ti));
>            return (DeploymentDao) pf.getProxy();
>
>For now I have turned lazy loading off; however I'd appreciate if somebody
>could provide a workaround, since lazy loading seems to be valuable.
>
>Thanks
>Reuben
>
>  
>
>>What's going on here? I'm using Spring's transactions, not the Ibatis
>>ones.
>>
>>
>>java.lang.NullPointerException
>>	at
>>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:78)
>>	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:98)
>>	at
>>com.ibatis.sqlmap.engine.mapping.result.loader.LazyResultLoader.invoke(LazyResultLoader.java:81)
>>	at $Proxy1.toArray(Unknown Source)
>>	at cnwk.deploy.beans.Operation.getScripts(Operation.java:142)
>>
>>
>>    
>>
>
>
>
>
>
>  
>


-- 
Il n'y a pas de mauvais langage, il n'y a que des bons programmeurs...


Mime
View raw message