Error using foreach index - java.lang.ClassCastException: [Ljava.lang.Integer; cannot be cast to java.lang.Integer

54 views
Skip to first unread message

Moacir Cardoso

unread,
Apr 3, 2014, 7:28:10 PM4/3/14
to mybati...@googlegroups.com

The error occurs when trying to use the index attribute on foreach tag


  <foreach collection="#{modulosOpcionais}" index="seq" item="idModuloOpcional">

 pTabCampoMovimentacaoContr(vInc).nom_campo_mov_contratual       := 'ID_MODULO_OPCIONAL';
 pTabCampoMovimentacaoContr(vInc).id_campo_mov_contratual        := 12;
 pTabCampoMovimentacaoContr(vInc).dsc_grupo_campo_mov_contratual := 'MODULO_OPCIONAL';
 pTabCampoMovimentacaoContr(vInc).id_grupo_campo_mov_contratual  := 7;
 pTabCampoMovimentacaoContr(vInc).dsc_conteudo_campo             :=  #{idModuloOpcional, jdbcType=INTEGER};
 pTabCampoMovimentacaoContr(vInc).num_sequencia_dado             := #{seq, jdbcType=INTEGER, javaType=java.lang.Integer};

 vInc := vInc + 1;
 vIndice := vIndice +1;
  </foreach>




### Error updating database.  Cause: java.lang.ClassCastException: [Ljava.lang.Integer; cannot be cast to java.lang.Integer
### The error may involve defaultParameterMap
### The error occurred while setting parameters

### Cause: java.lang.ClassCastException: [Ljava.lang.Integer; cannot be cast to java.lang.Integer
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:150)
at br.com.unimed.backoffice.service.server.dao.MovimentacaoContratualDAO.inclusaoModuloCliente(MovimentacaoContratualDAO.java:13)
at br.com.unimed.backoffice.service.server.service.ManutencaoSolicitacaoRestService.inserir(ManutencaoSolicitacaoRestService.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.cruxframework.crux.core.server.rest.core.dispatch.MethodInvoker.invoke(MethodInvoker.java:120)
... 28 more
Caused by: java.lang.ClassCastException: [Ljava.lang.Integer; cannot be cast to java.lang.Integer
at org.apache.ibatis.type.IntegerTypeHandler.setNonNullParameter(IntegerTypeHandler.java:23)
at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:46)
at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:77)
at org.apache.ibatis.executor.statement.CallableStatementHandler.parameterize(CallableStatementHandler.java:80)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:58)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:71)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:44)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:100)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:148)
... 35 more

Iwao AVE!

unread,
Apr 5, 2014, 9:33:15 AM4/5/14
to mybatis-user
Hi Moacir,

The error says that an array of java.lang.Integer is passed as a
parameter instead of java.lang.Integer.
Does the parameter class have an integer array property named 'seq'?
You may need to provide more details (the entire <update /> and the
parameter class definition) or a test case to get helpful replies.

Regards,
Iwao
Reply all
Reply to author
Forward
0 new messages