Results 1 to 3 of 3

Thread: Exception IBATiS lazy loading 1:M

  1. #1
    Join Date
    Aug 2004
    Location
    Athens, GA
    Posts
    20

    Default Exception IBATiS lazy loading 1:M

    Hello World,

    I'm getting this exception when I enable lazy loading on SQLMaps and try to access the M side of a 1:M relationship. If I disable lazy loading all runs as expected. Another topic regarding this is http://forum.springframework.org/showthread.php?t=9730 which was solved by adding transactions. As you can see from the stack trace it is hitting the transaction manger by the exception is still thrown. I would greatly appreciate any help someone can give me


    The Exception
    -----------------
    Code:
    java.lang.NullPointerException
    com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.endTransaction(SqlMapExecutorDelegate.java:465)
    com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.endTransaction(SqlMapSessionImpl.java:134)
    com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.endTransaction(SqlMapClientImpl.java:107)
    com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.autoEndTransaction(SqlMapExecutorDelegate.java:515)
    com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:381)
    com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:359)
    com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:90)
    com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:65)
    com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.getResult(ResultLoader.java:65)
    com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.loadObject(EnhancedLazyResultLoader.java:97)
    com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.invoke(EnhancedLazyResultLoader.java:80)
    $java.util.List$$EnhancerByCGLIB$$7e9071fc.iterator(<generated>)
    pcvm.reservation.domain.logic.ReservationServiceImpl.findReservation(ReservationServiceImpl.java:267)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:324)
    org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:59)
    org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:149)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:118)
    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:191)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:148)
    $Proxy1.findReservation(Unknown Source)
    SQLMap
    ----------
    Code:
    <resultMap id="reservationEntity-result" class="reservationEntity">
    	<result property="reservationNumber" column="CVMB40B_NORESV"/>
    	<result property="rentals" column="CVMB40B_NORESV" select="findRentals"/>
    	[other boring stuff...]
    </resultMap>
    
    <resultMap id="reservationRentalEntity-result" class="reservationRentalEntity">
    	<result property="vehicleNumber" column="CVMB40C_NOVEH"/>
    	[other boring stuff...]
    </resultMap>
    
    <select id="findReservation" parameterClass="java.util.Map" resultMap="reservationEntity-result">
    	SELECT *
    	FROM
    		PCVM.CVMB40B
    	WHERE 
    		CVMB40B_NORESV = #reservationNumber#
    </select>
    
    <select id="findRentals" parameterClass="java.lang.String" resultMap="reservationRentalEntity-result">
    	SELECT *
    	FROM
    		PCVM.CVMB40C
    	WHERE
    		CVMB40C_NORENTL = #value#
    </select>
    Transaction Props
    ---------------------
    Code:
    <prop key="find*">PROPAGATION_REQUIRED</prop>
    [/code]
    Last edited by Rod Johnson; Jan 18th, 2006 at 10:42 AM.

  2. #2
    Join Date
    Aug 2004
    Location
    Athens, GA
    Posts
    20

    Default

    Well, I've found some information on this if anyone else is having the same problem http://sourceforge.net/forum/forum.p...orum_id=206693

  3. #3

    Default NullPointerException during insert: use SqlMapClient.insert()

    For me, The problem for me was in my DAO:

    here is my implemented method:

    public class PollDAOIbatis extends BaseDAO implements PollDAO {

    protected SqlMapClient sqlMap = null;
    protected final Log logger = LogFactory.getLog(getClass());

    public void setSqlMapClient(SqlMapClient sqlMap) {
    this.sqlMap = sqlMap;
    }

    public void createPoll(Poll poll) throws Exception {


    try{
    sqlMap.startTransaction();

    sqlMap.insert("createPoll", poll);


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

    Note: here I am using the sqlMap.insert() method.
    Earlier I was using sqlMap.queryForObject() method.
    Its by using the queryForObject() mothod I was getting the NPE , but changing it to insert() , turned the world around me.

    Hope this works for you.

Similar Threads

  1. Context initialization failed
    By kanonmicke in forum Container
    Replies: 7
    Last Post: Sep 29th, 2005, 12:35 AM
  2. Replies: 0
    Last Post: Jul 11th, 2005, 05:49 PM
  3. iBatis lazy load transaction issues.
    By efpiva in forum Data
    Replies: 3
    Last Post: Jun 22nd, 2005, 06:20 PM
  4. Replies: 3
    Last Post: Nov 8th, 2004, 07:30 PM
  5. iBatis Unit Test with Lazy Loading
    By telcontar4 in forum Data
    Replies: 4
    Last Post: Aug 19th, 2004, 10:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •