ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: java.util.NoSuchElementException... on insert
Date Mon, 17 Jan 2005 20:12:24 GMT
First, I recommend upgrading to iBATIS 2.0.  The latest version of 1.x
is nearly a year old.

You can upgrade your 1.x documents to 2.0, while still using the 1.x
API (using the compatibility JAR files included with 2.0).

Second, dynamic SQL was not intended to support cascading
functionality.  You'll find that it's just as easy, and less code, if
you do this in your DAO or DAL rather than try to express it as XML.

Cheers,
Clinton


On Mon, 17 Jan 2005 10:12:24 -0800, Shai Topaz <shai@caxixi.net> wrote:
> Hi,
> 
> I am not sure this is a bug, so I thought i would post it to this
> mailing list first:
> 
> here is the sql map snippet:
> 
>     <dynamic-mapped-statement name="insertArtistGenres">
>         DELETE FROM artist_genres WHERE customer_id = #customerID;
>         <dynamic>
>             <iterate property="artistGenresList">
>                 INSERT INTO artist_genres (customer_id, genre_id)
>                 VALUES ( #customerID#, #artistGenresList[]# );
>             </iterate>
>         </dynamic>
>     </dynamic-mapped-statement>
> 
> I am basically trying to insert a series of values to an intermediate
> table so that a 1:M relationship is established as such:
> an artist may have 0 or more genres associated with it.
> 
> the dao java code looks like this:
> 
> public Object insert( Object parameterObject ) throws DaoException
>     {
>         GenerateID.artistID(parameterObject);
>         List statements = new LinkedList();
>         statements.add("insertArtist");
>         statements.add("updateArtistAddress");
>          statements.add("insertArtistGenres");
>         return super.batchUpdate( statements, parameterObject );
>     }
> the dao class extends a BaseDao class which executes the batch updates:
> 
> sqlMap.executeUpdate( (String)statements.get(i), parameterObject );
> //loop on the statements list
> 
> both the insertArtist and updateArtistAddress work fine,
> The bean passed is initialised properly - no faults there.
> only the last statement "insertArtistGenres" fails miserably and causes
> a rollback (see stacktrace below)
> 
> error message:
> 
> java.util.NoSuchElementException
> 
>     at java.util.StringTokenizer.nextToken(StringTokenizer.java:259)
> 
>     at
> com.ibatis.db.sqlmap.dynamic.DynamicMappedStatement.getSqlStatement(Unknown
> Source)
> 
>     at com.ibatis.db.sqlmap.MappedStatement.executeUpdate(Unknown Source)
> 
>     at com.ibatis.db.sqlmap.SqlMap.executeUpdate(Unknown Source)
> 
>     at com.blabla.dao.BaseDao.batchUpdate(BaseDao.java:192)
> 
>     at com.blabla.dao.ArtistDao.insert(ArtistDao.java:30)
> 
>     at
> com.blabla.action.DefaultDispatchAction.insert(DefaultDispatchAction.java:44)
> 
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 
>     at java.lang.reflect.Method.invoke(Method.java:324)
> 
>     at
> org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
> 
>     at
> org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
> 
>     at
> org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
> 
>     at
> org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
> 
>     at
> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
> 
>     at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)
> 
>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
> 
>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> 
>     at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
> 
>     at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
> 
>     at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
> 
>     at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
> 
>     at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
> 
>     at
> org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
> 
>     at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
> 
>     at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
> 
>     at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
> 
>     at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
> 
>     at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
> 
>     at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
> 
>     at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
> 
>     at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
> 
>     at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
> 
>     at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
> 
>     at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
> 
>     at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
> 
>     at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
> 
>     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
> 
>     at
> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
> 
>     at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
> 
>     at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
> 
>     at
> org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
> 
>     at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
> 
>     at java.lang.Thread.run(Thread.java:534)
> 
> I am running a Struts Webapp using tomcat 5.0, with postgres 8.0 beta5.0
> on a win32 platform.
> 
> I really don't understand why the dynamic multiple insert does not work.
> 
> Please help!
>

Mime
View raw message