<?XML version= "1.0" encoding= "UTF-8"?><!DOCTYPE Mapper Public "-//mybatis.org//dtd mapper 3.0//en" "Http://mybatis.org/dtd/mybatis-3-mapper.dtd "><Mappernamespace= "Com.oracle.mapper.AccountInfoMapper"><!--the full class name of the interface - <!--Type: The full class name of the entity class - <ResultmapID= "Baseresultmap"type= "Com.oracle.entity.AccountInfo"> <IDcolumn= "ID" Property= "id"Jdbctype= "DECIMAL" /> <resultcolumn= "USERNAME" Property= "UserName"Jdbctype= "VARCHAR" /> <resultcolumn= "PASSWORD" Property= "Password"Jdbctype= "VARCHAR" /> <resultcolumn= "GENDER" Property= "Gender"Jdbctype= "CHAR" /> <resultcolumn= "EMAIL" Property= "Email"Jdbctype= "VARCHAR" /> <resultcolumn= "Create_date" Property= "CreateDate"Jdbctype= "DATE" /> </Resultmap> <!--the ID is consistent with the method name in the interface - <SelectID= "Queryallaccountinfo"Resultmap= "Baseresultmap">Select ID, Username,password, GENDER, EMAIL, create_date from Account_info</Select> <InsertID= "Batchinsertaccountinfo"ParameterType= "Java.util.List">INSERT into Account_info (ID, Username,password,gender, email,create_date) (<foreachCollection= "List"Index=""Item= "AccountInfo"Separator= "UNION All">Select #{accountinfo.id}, #{accountinfo.username}, #{accountinfo.password }, #{accountinfo.gender}, #{accountinfo.email}, #{accountinfo.createdate} from Dual</foreach> ) </Insert> <InsertID= "Batchinsertaccountinfouseseq"ParameterType= "Java.util.List"> <SelectkeyResulttype= "Long"Keyproperty= "id"Order= "Before">SELECT Account_seq. Nextval from dual</Selectkey>INSERT into Account_info (ID, Username,password,gender, email,create_date) SELECT account_seq. Nextval, m.* from (<foreachCollection= "List"Index=""Item= "AccountInfo"Separator= "UNION All">Select #{accountinfo.username}, #{accountinfo.password}, #{accountinfo.ge NDEr}, #{accountinfo.email}, sysdate from dual</foreach>) M</Insert> <InsertID= "Insertone"ParameterType= "Com.oracle.entity.AccountInfo"> <SelectkeyResulttype= "Long"Keyproperty= "id"Order= "Before">SELECT Account_seq. Nextval from dual</Selectkey>INSERT into Account_info (ID, Username,password,gender, email,create_date) VALUES (#{id}, #{username}, #{password}, #{gender}, #{email}, Sysdate)
</Insert></Mapper>
Java enables bulk insertion of data into Oracle via MyBatis