boolean类型
MYSQL保存BOOLEAN值时用1代表TRUE,0代表FALSE,boolean在MySQL里的类型为tinyint(1),
MySQL里有四个常量:true,false,TRUE,FALSE,它们分别代表1,0,1,0,
mysql> select true,false,TRUE,FALSE;
+------+-------+------+-------+
| TRUE | FALSE | TRUE | FALSE |
+------+-------+------+-------+
| 1 | 0 | 1 | 0 |
+------+-------+------+-------+
可以如下插入boolean值:insert into [xxxx(xx)] values(true),当然也可以values(1);
举例如下:
mysql> alter table test add isOk boolean;
Query OK
mysql> desc test;
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| isOk | tinyint(1) | YES | | NULL | |
+-------+-------------+------+-----+---------+----------------+
mysql> insert into test(isOk) values(true);
Query OK
mysql> select isOk from test ;
+------+
| isOk |
+------+
| 1 |
+------+
=================
MySQL没有boolean类型。这也是比较奇怪的现象。例:
create table xs ( id int primary key, bl boolean )
|
这样是可以创建成功,但查看一下建表后的语句,就会发现,mysql把它替换成tinyint(1)。也就是说mysql把boolean=tinyInt了,但POJO类要定义成什么类型呢?
因为惯性思维,在java类中也把它定义成type。然后在Struts中使用<s:check/>标签。这就产生一个严重的问题了。<s:check>是boolean,而POJO去定义成byte。这样数据永远也无法提交,被struts的intercept拦截掉了。解决办法是在POJO类中定义成boolean,在mysql中定义成tinyint(1)。
分享到:
相关推荐
Boolean RT资源包,可用于Unity 几何体布尔运算
1- Real-time or per-click Boolean execution. 2- Material, UV and texture preservation. 3- Saving to prefab. 4- Constructive solid Geometry (CSG). 5- Smoothing of Boolean execution to keep smooth frame...
mybatis-generator自动生成工具,包含tinyint处理,自动获取数据库注释
下面小编就为大家带来一篇JS字符串false转boolean的方法(推荐)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
Unity 几何体布尔运算BooleanRT,Boolean RT.unitypackage,unity3d布尔运算插件。
boolean_approach
BooleanRT实时模型网格布尔运算插件 可以进行实时的模型合并、求差集、求交集等操作。 全网最好用的了,没有第二款。
Screen Space Boolean Subtract Shader 动态计算模型布尔值,源代码
The of Boolean Functions
The Handbook is divided into two ...part (Volume 1) is a completely self-contained treatment of the fundamentals of the subject, which mathematicians in various fields may find interesting and useful.
saliency detection a boolean map approach
Objective-C Boolean 变量 具体内容,请参考苹果开发者 Mike 的博文http://blog.sina.com.cn/s/blog_7aa21f320100r6ux.html
用作unity3D几何体的布尔运算包用作unity3D几何体的布尔运算包用作unity3D几何体的布尔运算包
下面小编就为大家带来一篇Java中Boolean与字符串或者数字1和0的转换实例。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
This textbook presents a survey of research on boolean functions, circuits, parallel computation models, function algebras, and proof systems. Its main aim is to elucidate the structure of "fast" ...
Boolean RT.unitypackage,unity3d布尔运算插件。
下面小编就为大家带来一篇详谈java中boolean和Boolean的区别。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧