Cannot delete a record using Mybatis

85 Views Asked by At

When conditions map contains a null value, record is not deleted.

map -> NAME:"Alise" - record deleted

map -> NAME:null - record not deleted

@Delete("<script>" +
        "DELETE FROM ${dataDestinationName}" +
        " WHERE" +
        "<foreach collection=\"conditions.entrySet()\" item=\"value\" index=\"key\" separator=\"AND\">" +
        "${key}=#{value}" +
        "</foreach>" +
        "</script>")
    void deleteData(@Param("dataDestinationName") String dataDestinationName,
                    @Param("conditions") HashMap<String, Object> conditions);

I would like to record be deleted in both cases.

0

There are 0 best solutions below