获得map
String insertCompId = "a,b,c";
String ttId = "a,b,c";
String ticketCode = "a";
String[] insertCompIdaa = insertCompId.split(",");
String[] ttidaa = ttId.split(",");
try{
sqlMapClient.startTransaction();
Map map = new HashMap();
List<TestInsert> tilist = new ArrayList<TestInsert>();
for (int i = 0; i < ttidaa.length; i++) {
for (int j = 0; j < insertCompIdaa.length; j++) {
TestInsert ti =new TestInsert();
ti.setTicketTypeId(ttidaa[i]);
ti.setTicketCodeType(ticketCode);
ti.setComponentId(insertCompIdaa[j]);
tilist.add(ti);
}
}
map.put("tilist", tilist);
.........
将上面得到的map,传入
<insert id="testInsertTicketCodeRelation" parameterClass="java.util.Map" >
insert all
<iterate property="tilist" conjunction=",">
into TICKET_TYPE_TICKET_CODE
(
TICKET_TYPE_TICKET_CODE_ID,
TICKET_TYPE_ID,
TICKET_CODE_TYPE,
COMPONENT_ID
)
values
(
TICKET_TYPE_AND_CODE_ID_SEQ.nextVal,
#tilist[].ticketTypeId#,
#tilist[].ticketCodeType#,
#tilist[].componentId#
)
</iterate>
select * from dual
</insert>
出错(当ttId和insertCompId为单字符,例如ttId=“a”insertCompId=“b”,这样的,是不会报错,只有为上面的有逗号的字符串时,才会出现这个错误)
ERROR [http-bio-8080-exec-4] LoggerFactory.invoke(38) | class com.hkt.engineering.oneoss.ticketing.dao.tickettype.impl.TicketTypeTicketCodeDAO.testInsertTicketCodeRelation() invoke error
ERROR [http-bio-8080-exec-4] LoggerFactory.invoke(39) | error info:
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred while applying a parameter map.
--- Check the EFT_TICKET_TYPE_TICKET_CODE.testInsertTicketCodeRelation-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: java.sql.SQLException: ORA-00928: 缺失 SELECT 关键字
请问,问题出在哪里了?