简体   繁体   English

如何在MySQL中使用mybatis更新位类型的表值字段?

[英]How to update the table value field which type is bit using mybatis in mysql?

I have a table called tbStudent. 我有一个名为tbStudent的表。 When I set the sex field using integers, and pass the parameter value in as 1 or 0 , it works just fine. 当我使用整数设置性别字段,并将参数值传递为1或0时,它工作得很好。 But now,when I try to update the sex field type using bits, and also pass the parameter value in as 1 or 0 , it does not work correctly. 但是现在,当我尝试使用位更新性别字段类型,并将参数值传递为1或0时,它无法正常工作。 I try to pass the parameter value in as true or false ,but it still does not work as intended. 我尝试将参数值传递为true或false,但仍无法按预期方式工作。 How to fix it so that it will work with bits? 如何修复它,使其可以与钻头一起使用? The error is: 错误是:

//I only pass in the value 1, why does it say too long?
Data truncation: Data too long for column 'SEX' at row 1;
nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: 
Data too long for column 'SEX' at row 1

尝试将其插入为b'1'或b'0'源: http ://dev.mysql.com/doc/refman/5.0/en/bit-field-literals.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM