-
Jun 2nd, 2009, 05:10 AM
#1
NullPointerException when we try to fetch the results of a query through LazyLoading
Hi,
We're getting a NullPointerException when we try to fetch the results of a query through LazyLoading.
The SqlMapClientFactoryBean has been configured as below:
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClient FactoryBean">
<property name="dataSource" ref="dataSourcePool"></property>
<property name="useTransactionAwareDataSource">
<value type="boolean">false</value>
</property>
<property name="transactionConfigClass" value="com.ibatis.sqlmap.engine.transaction.extern al.ExternalTransactionConfig" />
<property name="configLocation" value="classpath:com/abc/itk/xyz/support/connectivity/sqlmaps/sql-maps-config.xml" />
<property name="sqlMapClientProperties">
<props>
<prop key="@DB2Schema">${DB2_SCHEMA}</prop>
</props>
</property>
</bean>
Further, the iBatis sql-map-config settings have been defined as below:
<settings enhancementEnabled="false" useStatementNamespaces="true" maxTransactions="50" maxRequests="500" maxSessions="100"
lazyLoadingEnabled="true" cacheModelsEnabled="true" errorTracingEnabled="true"/>
The problem occurs when we try to open a document and fetch the related details attached with it.
1) Setting the ClientTemplate instance of class Defect
<resultMap id="partialDefectForCopyingResultMap" class="Defect" extends="partialDefectResultMap">
<result property="template" column="TMPL_ID" select="templateCSG.getTemplateCsgById" />
</resultMap>
2) Setting the templateFields property of class ClientTemplate
<resultMap id="templateResultMap" class="templateCSG">
<result property="id" column="TMPL_ID" />
<result property="name" column="TMPL_NM" />
<result property="parentTemplate" column="PRNT_TMPL_ID" select="templateCSG.getParentTemplateCsgById"/>
<result property="templateFields" column="TMPL_ID" select="templateFieldCSG.getTemplateFields" />
</resultMap>
3) Setting the list of conditions.
<resultMap id="templateFieldResultMap" class="clientTemplateField">
<result property="id" column="TMPL_FLD_ID" javaType="java.lang.Integer" jdbcType="INTEGER" />
<result property="conditionsBySourceField" column="{fieldId=TMPL_FLD_ID,templateCategory=TMPL _CAT}" select="condition.getTemplateFieldConditionsBySour ce"/>
</resultMap>
4) Setting the Condition instance
<resultMap id= "templateFieldconditonsMap" class="Condition">
<result property="id" column="TMPL_FLD_COND_ID" javaType="java.lang.Integer" jdbcType="INTEGER" />
<result property="conditionType" column="COND_TYPE_ID" select="validValue.getValidValueById" />
<result property="conditionExpression" column="COND_EXPN_TX" javaType="java.lang.String" jdbcType="VARCHAR" />
<result property="sourceConditions" column="{condId=TMPL_FLD_COND_ID,docType=TMPL_CAT} " select="condition.getConditionStatements" />
<result property="value" column="{condId=TMPL_FLD_COND_ID,templateId=TMPL_I D}" select="condition.getConditionAction"/>
<discriminator column="TMPL_CAT" javaType="java.lang.String" >
<subMap value="TMPL_CLNT" resultMap="csgTrgtTemplateField" />
<subMap value="TMPL_SPRT" resultMap="issueTrgtTemplateField" />
</discriminator>
</resultMap>
5)
<resultMap id="csgTrgtTemplateField" class="Condition" extends="templateFieldconditonsMap">
<result property="targetField" column="TRGT_TMPL_FLD_ID" select="templateFieldCSG.getPartialTemplateFieldBy Id"/>
</resultMap>
6) Set the ConditionStatement instance
<resultMap id="conditonStatementResultMap" class="ConditionStatement">
<result property="id" column="COND_STMT_ID" javaType="java.lang.Integer" jdbcType="INTEGER" />
<result property="operator" column="OPR_CD" select="validValue.getValidValueById" />
<result property="compareValue" column="CMPR_VL" javaType="java.lang.String" jdbcType="VARCHAR" />
<discriminator column="TMPL_CAT" javaType="java.lang.String" >
<subMap value="TMPL_CLNT" resultMap="csgSrcTemplateField" />
<subMap value="TMPL_SPRT" resultMap="issueSrcTemplateField" />
</discriminator>
</resultMap>
<resultMap id="conditonActnResultMap" class="java.util.HashMap">
<result property="type" column="TYPE_CD" select="validValue.getValidValueById"/>
<discriminator column="TYPE_CD" javaType="java.lang.String" >
<subMap value="ACTN_LIST" resultMap="listMap" />
<subMap value="ACTN_LIST_ITM" resultMap="listItemMap" />
<subMap value="ACTN_KYWD" resultMap="keywordMap" />
<subMap value="ACTN_KYWD_ITM" resultMap="keywordItemMap" />
<subMap value="ACTN_ASSC" resultMap="associateMap" />
<subMap value="ACTN_CLNT" resultMap="clientMap" />
<subMap value="ACTN_WKGP" resultMap="workgroupMap" />
<subMap value="ACTN_PROJ" resultMap="projectMap" />
<subMap value="ACTN_SHRD_SRVC" resultMap="shardSrvcMap" />
<subMap value="ACTN_EL" resultMap="elementMap" />
<subMap value="ACTN_NM" resultMap="valueMap" />
<subMap value="ACTN_BOOL" resultMap="valueMap" />
<subMap value="ACTN_DT" resultMap="valueMap" />
<subMap value="ACTN_TS" resultMap="valueMap" />
<subMap value="ACTN_TX" resultMap="valueMap" />
<subMap value="ACTN_TMPL" resultMap="templateMap" />
<subMap value="ACTN_SHRD_SRVC_WKGP_PRSN" resultMap="shrdSrvcWkgpPrsnMap" />
</discriminator>
</resultMap>
<resultMap id="csgSrcTemplateField" class="ConditionStatement" extends="conditonStatementResultMap">
<result property="sourceField" column="SRC_TMPL_FLD_ID" select="templateFieldCSG.getPartialTemplateFieldBy Id"/>
</resultMap>
<resultMap id="validValueResultMap" class="validValue">
<result property="id" column="VLDV_ID" javaType="java.lang.String" jdbcType="VARCHAR" />
<result property="type" column="VLDV_TYPE_NM" javaType="java.lang.String" jdbcType="VARCHAR" />
<result property="code" column="VLDV_CD" javaType="java.lang.String" jdbcType="VARCHAR" />
<result property="value" column="VLDV_VL" javaType="java.lang.String" jdbcType="VARCHAR" />
<result property="description" column="VLDV_DS" javaType="java.lang.String" jdbcType="VARCHAR" />
</resultMap>
The error that we get is as follows:
com.hewitt.itk.maestro.csg.model.template.ClientTe mplate. Cause: java.lang.NullPointerException
Caused by: com.ibatis.common.beans.ProbeException: Could not set property 'templateFields' for com.hewitt.itk.maestro.csg.model.template.ClientTe mplate. Cause: java.lang.NullPointerException
at com.ibatis.sqlmap.engine.mapping.statement.General Statement.executeQueryWithCallback(GeneralStatemen t.java:188)
at com.ibatis.sqlmap.engine.mapping.statement.General Statement.executeQueryForObject(GeneralStatement.j ava:104)
at com.ibatis.sqlmap.engine.mapping.statement.Caching Statement.executeQueryForObject(CachingStatement.j ava:79)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelega te.queryForObject(SqlMapExecutorDelegate.java:565)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelega te.queryForObject(SqlMapExecutorDelegate.java:540)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.qu eryForObject(SqlMapSessionImpl.java:106)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.que ryForObject(SqlMapClientImpl.java:84)
at com.ibatis.sqlmap.engine.mapping.result.loader.Res ultLoader.getResult(ResultLoader.java:77)
at com.ibatis.sqlmap.engine.mapping.result.loader.Laz yResultLoader.loadResult(LazyResultLoader.java:72)
at com.ibatis.sqlmap.engine.mapping.result.loader.Res ultLoader.loadResult(ResultLoader.java:56)
at com.ibatis.sqlmap.engine.mapping.result.BasicResul tMap.getNestedSelectMappingValue(BasicResultMap.ja va:504)
at com.ibatis.sqlmap.engine.mapping.result.BasicResul tMap.getResults(BasicResultMap.java:340)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.han dleResults(SqlExecutor.java:375)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.han dleMultipleResults(SqlExecutor.java:295)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.exe cuteQuery(SqlExecutor.java:186)
at com.ibatis.sqlmap.engine.mapping.statement.General Statement.sqlExecuteQuery(GeneralStatement.java:20 5)
at com.ibatis.sqlmap.engine.mapping.statement.General Statement.executeQueryWithCallback(GeneralStatemen t.java:173)
... 106 more
Note that this is not a sporadic error and the document successfully opens most of the time. However at random times it throws the above exception. I think that this is not an application issue which would have caused the error to appear
everytime the document was read. Was wondering if this an issue related to iBatis - 2.2 version.
Any help in this regard is highly appreciated.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules