I recently took on a project and found that the previous guy in the code was having problems writing as SQL conditions when using enumerations. The magic is that all the values of the int field in the data are 0. As a result, this problem was not detected by the test (here I think the tester also made a small mistake). The enumeration class code looks like this:
public enum DelUtil {
NO_DEL("Not deleted".0), DELETED("Deleted".1);
private String desc;
private int val;
private DelUtil( String desc, int val){
this.desc = desc;
this.val = val;
}
public String getDesc(a) {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public int getVal(a) {
return val;
}
public void setVal(int val) {
this.val = val; }}Copy the code
Is_del =’NO_DEL’; mybatis =’NO_DEL’; The correct way to write it should be delutil.no_del.getVal ().
Is_del =’NO_DEL’; is_del=0; Create a table as follows (score field int type)
Mysql > select String from left to right; if there are no numbers at the left of the String, 0 will be truncated.