First, let's take an example of an array of arguments passed
//Bulk Delete@Test Public voidDeleteUser () {sqlsession session=sessionfactory.opensession (); Usermapper Usermapper=session.getmapper (Usermapper.class); intNum=0; int[] arr=New int[]{10,11}; Try{num=Usermapper.deleteuser (arr); Session.commit (); } Catch(Exception e) {//TODO auto-generated Catch blockE.printstacktrace (); } if(num<=0) {System.out.println ("Delete Failed"); }Else{System.out.println ("Delete Succeeded"); }
Then our interface should be written as:
and our SQL mapping file should be written as:
In other words: When the interface is an array type, in the mapping file in the collection to be used to receive array;
But when our interface is written in this form:
There should be a corresponding change in our SQL mapping file as well:
MyBatis problem of passing parameters when bulk Delete