Announcement Announcement Module
Collapse
No announcement yet.
Ibatis question Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ibatis question

    I have a question on ibatis and Spring hitting MS SQL Server. We are running into a problem witht he keySelect tag. Anyone have an idea what could be the problem?

    Thanks!

    We are using a class that extends this :

    public abstract class Entity {

    private String id = "";

    public Entity() {
    super();
    }

    public boolean isNew()
    {
    return "".equals(id);
    }

    public String getId() {
    return id;
    }

    public void setId(String id) {
    this.id = id;
    }
    }

    we then use the following in the xml configuration file for the class:

    <insert id="insertYumAFASession" parameterClass="yumafasession">
    insert into tSession (
    vData,
    State,
    LastActivity
    )
    values (
    #data#,
    #state#,
    #lastactivity#
    )
    <selectKey resultClass="int" keyProperty="id">
    Select @@IDENTITY
    </selectKey>
    </insert>

    This results in the following error (IBM Websphere 5.1)

    [8/18/04 15:23:48:562 EDT] 32a532a5 WebGroup I SRVE0180I: [AFA] [/AFA] [Servlet.LOG]: Tester: init
    [8/18/04 15:23:48:672 EDT] 32a532a5 DataSourceTra I org.springframework.jdbc.datasource.DataSourceTran sactionObject JDBC 3.0 Savepoint class is available
    [8/18/04 15:23:48:832 EDT] 32a532a5 SQLErrorCodeS W org.springframework.jdbc.support.SQLErrorCodeSQLEx ceptionTranslator Unable to translate SQLException with errorCode '0', will now try the fallback translator
    [8/18/04 15:23:48:842 EDT] 32a532a5 SQLStateSQLEx I org.springframework.jdbc.support.SQLStateSQLExcept ionTranslator Translating SQLException with SQLState 'HY004' and errorCode '0' and message [
    --- The error occurred in com/yum/iam/afa/data/ibatis/maps/YumAFASession.xml.
    --- The error occurred while applying a parameter map.
    --- Check the insertYumAFASession-InlineParameterMap.
    --- Check the statement (update failed).
    --- Cause: java.sql.SQLException: Not implemented (type is Types.NULL)]; SQL was [(mapped statement)] for task [SqlMapClientTemplate]
    [8/18/04 15:23:49:263 EDT] 32a532a5 WebGroup E SRVE0026E: [Servlet Error]-[Tester]: org.springframework.jdbc.UncategorizedSQLException : (SqlMapClientTemplate): encountered SQLException [
    --- The error occurred in com/yum/iam/afa/data/ibatis/maps/YumAFASession.xml.
    --- The error occurred while applying a parameter map.
    --- Check the insertYumAFASession-InlineParameterMap.
    --- Check the statement (update failed).
    --- Cause: java.sql.SQLException: Not implemented (type is Types.NULL)]; nested exception is com.ibatis.common.jdbc.exception.NestedSQLExceptio n:
    --- The error occurred in com/yum/iam/afa/data/ibatis/maps/YumAFASession.xml.
    --- The error occurred while applying a parameter map.
    --- Check the insertYumAFASession-InlineParameterMap.
    --- Check the statement (update failed).
    --- Cause: java.sql.SQLException: Not implemented (type is Types.NULL)
    com.ibatis.common.jdbc.exception.NestedSQLExceptio n:
    --- The error occurred in com/yum/iam/afa/data/ibatis/maps/YumAFASession.xml.
    --- The error occurred while applying a parameter map.
    --- Check the insertYumAFASession-InlineParameterMap.
    --- Check the statement (update failed).
    --- Cause: java.sql.SQLException: Not implemented (type is Types.NULL)
    Caused by: java.sql.SQLException: Not implemented (type is Types.NULL)
    at java.lang.Throwable.<init>(Throwable.java)
    at java.lang.Throwable.<init>(Throwable.java:73)
    at java.sql.SQLException.<init>(SQLException.java:52)
    at com.ibatis.common.jdbc.exception.NestedSQLExceptio n.<init>(NestedSQLException.java:43)
    at com.ibatis.sqlmap.engine.mapping.statement.General Statement.executeUpdate(GeneralStatement.java:74)
    at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelega te.insert(SqlMapExecutorDelegate.java:227)
    at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.in sert(SqlMapSessionImpl.java:60)
    at org.springframework.orm.ibatis.SqlMapClientTemplat e$10.doInSqlMapClient(SqlMapClientTemplate.java:27 3)
    at org.springframework.orm.ibatis.SqlMapClientTemplat e.execute(SqlMapClientTemplate.java:140)
    at org.springframework.orm.ibatis.SqlMapClientTemplat e.insert(SqlMapClientTemplate.java:271)
    at com.yum.iam.afa.data.ibatis.SqlMapYumAfaSessionDao .insertYumAFASession(SqlMapYumAfaSessionDao.java:2 5)
    at com.yum.iam.afa.session.YumAFASessionManager.getAF ASession(YumAFASessionManager.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:41)
    at java.lang.reflect.Method.invoke(Method.java:386)
    at org.springframework.aop.framework.AopProxyUtils.in vokeJoinpointUsingReflection(AopProxyUtils.java:61 )
    at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:151)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :120)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:57)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :140)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:153)
    at $Proxy0.getAFASession(Unknown Source)
    at com.yum.iam.afa.web.Tester.doGet(Tester.java:39)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
    at com.ibm.ws.webcontainer.servlet.StrictServletInsta nce.doService(StrictServletInstance.java:110)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleSer vlet._service(StrictLifecycleServlet.java:174)
    at com.ibm.ws.webcontainer.servlet.IdleServletState.s ervice(StrictLifecycleServlet.java:313)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleSer vlet.service(StrictLifecycleServlet.java:116)
    at com.ibm.ws.webcontainer.servlet.ServletInstance.se rvice(ServletInstance.java:283)
    at com.ibm.ws.webcontainer.servlet.ValidServletRefere nceState.dispatch(ValidServletReferenceState.java: 42)
    at com.ibm.ws.webcontainer.servlet.ServletInstanceRef erence.dispatch(ServletInstanceReference.java:40)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.handleWebAppDispatch(WebAppRequestDispatcher. java:983)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.dispatch(WebAppRequestDispatcher.java:564)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.forward(WebAppRequestDispatcher.java:200)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForwar d(WebAppInvoker.java:119)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleIn vocationHook(WebAppInvoker.java:276)
    at com.ibm.ws.webcontainer.cache.invocation.CachedInv ocation.handleInvocation(CachedInvocation.java:71)
    at com.ibm.ws.webcontainer.srp.ServletRequestProcesso r.dispatchByURI(ServletRequestProcessor.java:182)
    at com.ibm.ws.webcontainer.oselistener.OSEListenerDis patcher.service(OSEListener.java:334)
    at com.ibm.ws.webcontainer.http.HttpConnection.handle Request(HttpConnection.java:56)
    at com.ibm.ws.http.HttpConnection.readAndHandleReques t(HttpConnection.java:618)
    at com.ibm.ws.http.HttpConnection.run(HttpConnection. java:439)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.j ava)
    Caused by: java.sql.SQLException: Not implemented (type is Types.NULL)
    at java.lang.Throwable.<init>(Throwable.java)
    at java.lang.Throwable.<init>(Throwable.java:73)
    at java.sql.SQLException.<init>(SQLException.java:73)
    at net.sourceforge.jtds.jdbc.ParameterUtils.createPar ameterMapping(ParameterUtils.java:259)
    at net.sourceforge.jtds.jdbc.PreparedStatement_base.f indOrCreateProcedure(PreparedStatement_base.java:1 50)
    at net.sourceforge.jtds.jdbc.PreparedStatement_base.e xecute(PreparedStatement_base.java:131)
    at net.sourceforge.jtds.jdbc.PreparedStatement_base.e xecuteUpdate(PreparedStatement_base.java:290)
    at org.apache.commons.dbcp.DelegatingPreparedStatemen t.executeUpdate(DelegatingPreparedStatement.java:1 01)
    at com.ibatis.sqlmap.engine.execution.SqlExecutor.exe cuteUpdate(SqlExecutor.java:57)
    at com.ibatis.sqlmap.engine.mapping.statement.General Statement.sqlExecuteUpdate(GeneralStatement.java:1 83)
    at com.ibatis.sqlmap.engine.mapping.statement.General Statement.executeUpdate(GeneralStatement.java:61)
    at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelega te.insert(SqlMapExecutorDelegate.java:227)
    at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.in sert(SqlMapSessionImpl.java:60)
    at org.springframework.orm.ibatis.SqlMapClientTemplat e$10.doInSqlMapClient(SqlMapClientTemplate.java:27 3)
    at org.springframework.orm.ibatis.SqlMapClientTemplat e.execute(SqlMapClientTemplate.java:140)
    at org.springframework.orm.ibatis.SqlMapClientTemplat e.insert(SqlMapClientTemplate.java:271)
    at com.yum.iam.afa.data.ibatis.SqlMapYumAfaSessionDao .insertYumAFASession(SqlMapYumAfaSessionDao.java:2 5)
    at com.yum.iam.afa.session.YumAFASessionManager.getAF ASession(YumAFASessionManager.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:41)
    at java.lang.reflect.Method.invoke(Method.java:386)
    at org.springframework.aop.framework.AopProxyUtils.in vokeJoinpointUsingReflection(AopProxyUtils.java:61 )
    at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:151)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :120)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:57)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :140)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:153)
    at $Proxy0.getAFASession(Unknown Source)
    at com.yum.iam.afa.web.Tester.doGet(Tester.java:39)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
    at com.ibm.ws.webcontainer.servlet.StrictServletInsta nce.doService(StrictServletInstance.java:110)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleSer vlet._service(StrictLifecycleServlet.java:174)
    at com.ibm.ws.webcontainer.servlet.IdleServletState.s ervice(StrictLifecycleServlet.java:313)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleSer vlet.service(StrictLifecycleServlet.java:116)
    at com.ibm.ws.webcontainer.servlet.ServletInstance.se rvice(ServletInstance.java:283)
    at com.ibm.ws.webcontainer.servlet.ValidServletRefere nceState.dispatch(ValidServletReferenceState.java: 42)
    at com.ibm.ws.webcontainer.servlet.ServletInstanceRef erence.dispatch(ServletInstanceReference.java:40)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.handleWebAppDispatch(WebAppRequestDispatcher. java:983)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.dispatch(WebAppRequestDispatcher.java:564)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.forward(WebAppRequestDispatcher.java:200)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForwar d(WebAppInvoker.java:119)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleIn vocationHook(WebAppInvoker.java:276)
    at com.ibm.ws.webcontainer.cache.invocation.CachedInv ocation.handleInvocation(CachedInvocation.java:71)
    at com.ibm.ws.webcontainer.srp.ServletRequestProcesso r.dispatchByURI(ServletRequestProcessor.java:182)
    at com.ibm.ws.webcontainer.oselistener.OSEListenerDis patcher.service(OSEListener.java:334)
    at com.ibm.ws.webcontainer.http.HttpConnection.handle Request(HttpConnection.java:56)
    at com.ibm.ws.http.HttpConnection.readAndHandleReques t(HttpConnection.java:618)
    at com.ibm.ws.http.HttpConnection.run(HttpConnection. java:439)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.j ava)

    Caused by:
    java.sql.SQLException: Not implemented (type is Types.NULL)
    at java.lang.Throwable.<init>(Throwable.java)
    at java.lang.Throwable.<init>(Throwable.java:73)
    at java.sql.SQLException.<init>(SQLException.java:73)
    at net.sourceforge.jtds.jdbc.ParameterUtils.createPar ameterMapping(ParameterUtils.java:259)
    at net.sourceforge.jtds.jdbc.PreparedStatement_base.f indOrCreateProcedure(PreparedStatement_base.java:1 50)
    at net.sourceforge.jtds.jdbc.PreparedStatement_base.e xecute(PreparedStatement_base.java:131)
    at net.sourceforge.jtds.jdbc.PreparedStatement_base.e xecuteUpdate(PreparedStatement_base.java:290)
    at org.apache.commons.dbcp.DelegatingPreparedStatemen t.executeUpdate(DelegatingPreparedStatement.java:1 01)
    at com.ibatis.sqlmap.engine.execution.SqlExecutor.exe cuteUpdate(SqlExecutor.java:57)
    at com.ibatis.sqlmap.engine.mapping.statement.General Statement.sqlExecuteUpdate(GeneralStatement.java:1 83)
    at com.ibatis.sqlmap.engine.mapping.statement.General Statement.executeUpdate(GeneralStatement.java:61)
    at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelega te.insert(SqlMapExecutorDelegate.java:227)
    at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.in sert(SqlMapSessionImpl.java:60)
    at org.springframework.orm.ibatis.SqlMapClientTemplat e$10.doInSqlMapClient(SqlMapClientTemplate.java:27 3)
    at org.springframework.orm.ibatis.SqlMapClientTemplat e.execute(SqlMapClientTemplate.java:140)
    at org.springframework.orm.ibatis.SqlMapClientTemplat e.insert(SqlMapClientTemplate.java:271)
    at com.yum.iam.afa.data.ibatis.SqlMapYumAfaSessionDao .insertYumAFASession(SqlMapYumAfaSessionDao.java:2 5)
    at com.yum.iam.afa.session.YumAFASessionManager.getAF ASession(YumAFASessionManager.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:41)
    at java.lang.reflect.Method.invoke(Method.java:386)
    at org.springframework.aop.framework.AopProxyUtils.in vokeJoinpointUsingReflection(AopProxyUtils.java:61 )
    at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:151)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :120)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:57)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :140)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:153)
    at $Proxy0.getAFASession(Unknown Source)
    at com.yum.iam.afa.web.Tester.doGet(Tester.java:39)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
    at com.ibm.ws.webcontainer.servlet.StrictServletInsta nce.doService(StrictServletInstance.java:110)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleSer vlet._service(StrictLifecycleServlet.java:174)
    at com.ibm.ws.webcontainer.servlet.IdleServletState.s ervice(StrictLifecycleServlet.java:313)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleSer vlet.service(StrictLifecycleServlet.java:116)
    at com.ibm.ws.webcontainer.servlet.ServletInstance.se rvice(ServletInstance.java:283)
    at com.ibm.ws.webcontainer.servlet.ValidServletRefere nceState.dispatch(ValidServletReferenceState.java: 42)
    at com.ibm.ws.webcontainer.servlet.ServletInstanceRef erence.dispatch(ServletInstanceReference.java:40)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.handleWebAppDispatch(WebAppRequestDispatcher. java:983)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.dispatch(WebAppRequestDispatcher.java:564)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.forward(WebAppRequestDispatcher.java:200)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForwar d(WebAppInvoker.java:119)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleIn vocationHook(WebAppInvoker.java:276)
    at com.ibm.ws.webcontainer.cache.invocation.CachedInv ocation.handleInvocation(CachedInvocation.java:71)
    at com.ibm.ws.webcontainer.srp.ServletRequestProcesso r.dispatchByURI(ServletRequestProcessor.java:182)
    at com.ibm.ws.webcontainer.oselistener.OSEListenerDis patcher.service(OSEListener.java:334)
    at com.ibm.ws.webcontainer.http.HttpConnection.handle Request(HttpConnection.java:56)
    at com.ibm.ws.http.HttpConnection.readAndHandleReques t(HttpConnection.java:618)
    at com.ibm.ws.http.HttpConnection.run(HttpConnection. java:439)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.j ava)

  • #2
    L

    Just a hunch, but this may have nothing to do with reading the generated key value, but the values that you are inserting into the table. iBatis is possibly getting confused about what type one of the paramters should be set to. Normally it can figure this out by looking at the type of the JavaBean properties going in (or if you feed it a Map of values), the value types, but I've seen a few cases where you need to give it some help. In your mapping statement, try qualifying the SQL types for each parameter. Again, you normally don't have to do this, but I think it's getting confused on one of them.

    Regards,

    Comment


    • #3
      Doh

      This is a case of staring at code to much

      We recently changed the db from UUID to int so we can use @@Identity and of course I did forget to update the Entity class.

      Go figure.

      Comment

      Working...
      X