I use mysql type tinyint(1) for rabbitmqFlag field.BUT,not as excepted,actually,the value -1 or >0 will map to true.other will map to false. Usually,we think 0 is false,other is true.Why?
@Data
public class User implements Serializable {
private Long id;
private String name;
private Integer age;
private Boolean rabbitmqFlag;
}
@Mapper
public interface UserMapper {
@Select("SELECT * FROM user1 WHERE rabbitmq_flag = 0")
List<User> findUnSend();
}
MyBatis does not process the numeric value.
It just returns the result of ResultSet#getBoolean
.
According to the driver's source code comment , it's for compatibility with the ODBC driver, etc..
public Boolean createFromLong(long l) {
// Goes back to ODBC driver compatibility, and VB/Automation Languages/COM, where in Windows "-1" can mean true as well.
return (l == -1 || l > 0);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.