求助关于oracle+mybaties批量插入数据的问题
请问下这是哪里的问题,求指教。
Mapper:
<insert id="insertrolefun" parameterType="java.util.List">
insert into role_function(roleid,functionid)
<foreach open="(" collection="list" item="item" index="index" separator="union all" close=")">
select
#{item.roleid},
#{item.functionid}
from dual
</foreach>
</insert>
SQL: insert into role_function(roleid,functionid) ( select ?, ? from dual union all select ?, ? from dual )
### Cause: java.sql.SQLException: ORA-00933: SQL 命令未正确结束
; bad SQL grammar []; nested exception is java.sql.SQLException: ORA-00933: SQL 命令未正确结束
] with root cause
java.sql.SQLException: ORA-00933: SQL 命令未正确结束
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:330)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:287)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:744)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:215)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:965)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1169)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3338)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3444)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:169)
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:606)
at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:58)
at com.sun.proxy.$Proxy22.execute(Unknown Source)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
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:606)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:59)
at com.sun.proxy.$Proxy20.update(Unknown Source)
调用:
List<RoleFun> list=new ArrayList<RoleFun>();
for(int i=0;i<funids.length;i++){
if(funids!=null&&funids[i] !=""){
RoleFun rolefun=new RoleFun();
rolefun.setFunctionid(funids[i]);
rolefun.setRoleid(roleid);
list.add(rolefun);
}
}
roledao.insertrolefun(list);
Mapper:
<insert id="insertrolefun" parameterType="java.util.List">
insert into role_function(roleid,functionid)
<foreach open="(" collection="list" item="item" index="index" separator="union all" close=")">
select
#{item.roleid},
#{item.functionid}
from dual
</foreach>
</insert>
SQL: insert into role_function(roleid,functionid) ( select ?, ? from dual union all select ?, ? from dual )
### Cause: java.sql.SQLException: ORA-00933: SQL 命令未正确结束
; bad SQL grammar []; nested exception is java.sql.SQLException: ORA-00933: SQL 命令未正确结束
] with root cause
java.sql.SQLException: ORA-00933: SQL 命令未正确结束
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:330)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:287)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:744)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:215)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:965)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1169)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3338)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3444)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:169)
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:606)
at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:58)
at com.sun.proxy.$Proxy22.execute(Unknown Source)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
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:606)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:59)
at com.sun.proxy.$Proxy20.update(Unknown Source)
调用:
List<RoleFun> list=new ArrayList<RoleFun>();
for(int i=0;i<funids.length;i++){
if(funids!=null&&funids[i] !=""){
RoleFun rolefun=new RoleFun();
rolefun.setFunctionid(funids[i]);
rolefun.setRoleid(roleid);
list.add(rolefun);
}
}
roledao.insertrolefun(list);
...全文
相关推荐
spring+springMVC+mybaties+oracle+生产百万的数据库
这个项目“spring+springMVC+mybaties+oracle+生产百万的数据库”显然旨在实现这样的目标,结合了Java后端开发的主流框架与Oracle数据库的强大功能。
spring+spring mvc + mybaties的整合需要的包
**数据库驱动**: - 根据所使用的数据库(如MySQL、Oracle等),需要相应的JDBC驱动包,如`mysql-connector-java`。5.
mybaties自动生成实体类及映射文件
MBG的优势在于,它支持多种数据库,包括但不限于MySQL、Oracle、SQL Server等,具有很好的兼容性。而且,MBG的配置文件支持条件判断和循环,可以根据不同的需求生成不同风格的代码。
mybaties中lib.zip
`(对于Oracle)等。
Oracle在Mybatis中SQL语句的配置方法
Oracle在Mybatis中的SQL语句配置是开发过程中常见的一步,特别是在处理与Oracle数据库交互时。Mybatis是一个强大的持久层框架,它允许开发者通过XML或注解的方式配置SQL语句,而


