Hello list,
I'm using iBatis with SpringFramework. I have an application that is
working fine today, but without lazy loading. If I enable lazy-load but
does not enable enhancements, it seems that lazy loading does not works,
because I can see the same number of selects going to my database.
If I enable both lazy-load and enhancements, there is just one select
going to my database, witch is correct, but when I try to access a field
of my bean, I get a NullPointerException. It seems that it's something
related to Transactions into a Session.
If I disable transaction in SpringFramework, I continue to have the same
error. Can someone help me? Here are my iBatis map and the error I get.
************** Settings ********************
<settings
cacheModelsEnabled="true"
enhancementEnabled="true"
lazyLoadingEnabled="true"
useStatementNamespaces="false"
/>
********* User.xml Map, with some information ommited. *********
<cacheModel id="userCache" type="MEMORY" readOnly="false">
<flushInterval hours="24"/>
<flushOnExecute statement="update-user-info"/>
<flushOnExecute statement="insert-user"/>
<property name="reference-type" value="WEAK"/>
</cacheModel>
<cacheModel id="roleCache" type="MEMORY" readOnly="false">
<flushInterval hours="24"/>
<flushOnExecute statement="insert-role"/>
<flushOnExecute statement="remove-role"/>
<property name="reference-type" value="WEAK"/>
</cacheModel>
<resultMap id="userResult" class="br.com.gwe.domain.User">
<result property="login" column="username"/>
<result property="name" column="name"/>
<result property="telephone" column="telephone"/>
<result property="celphone" column="celphone"/>
<result property="roles" column="username" select="get-role"/>
</resultMap>
<resultMap id="roleResult" class="br.com.gwe.domain.Role">
<result property="code" column="authority"/>
<result property="description" column="description"/>
</resultMap>
<statement id="get-user-by-login" resultMap="userResult"
parameterClass="java.lang.String" cacheModel="userCache">
select username, name, telephone, celphone from users where username =
#param#
</statement>
<statement id="get-role" resultMap="roleResult"
parameterClass="java.lang.String" cacheModel="roleCache">
select * from authorities, valid_authorities where username = #param#
and authorities.authority = valid_authorities.authority
</statement>
************* Error *********************
java.lang.NullPointerException
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.endTransaction(SqlMapExecutorDelegate.java:776)
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.endTransaction(SqlMapSessionImpl.java:141)
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.endTransaction(SqlMapClientImpl.java:114)
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.autoEndTransaction(SqlMapExecutorDelegate.java:860)
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:617)
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:584)
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:105)
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:77)
com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.getResult(ResultLoader.java:72)
com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.loadObject(EnhancedLazyResultLoader.java:130)
com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.invoke(EnhancedLazyResultLoader.java:113)
$java.util.List$$EnhancerByCGLIB$$7e9071fc.toString(<generated>)
java.lang.String.valueOf(String.java:2131)
java.lang.StringBuffer.append(StringBuffer.java:370)
br.com.gwe.web.controller.UserController.formBackingObject(UserController.java:109)
org.springframework.web.servlet.mvc.AbstractFormController.showNewForm(AbstractFormController.java:270)
org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:240)
org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:128)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:522)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:321)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:70)
net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter.doFilter(SecurityEnforcementFilter.java:169)
net.sf.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:105)
net.sf.acegisecurity.ui.AbstractIntegrationFilter.doFilter(AbstractIntegrationFilter.java:170)
net.sf.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:105)
net.sf.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:333)
net.sf.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:105)
If you need more information, just ask me that I can provide it. I've
ommited a lot of XML, since it is a full application and it would flood
this email.
--
Eduardo Piva
GWE Software
+55 (19) 3254-7633
+55 (19) 8114-9488
www.gwe.com.br