mybatis-generator reverse engineering to generate boolean field solution

Generate code through reverse engineering. If the field is int(1) or tinyint(1), the Boolean type will be automatically generated. It has to be said that it is a pit. Originally, my status field is used to record the status. Of course, there are not only 0 and 1, but also 2 or 3. This time, turn it into a boolean type for me, and let me know how to distinguish it. like this

mybatis-generator reverse engineering to generate boolean field solution

Solution

Method 1. Directly modify the field length, such as int(2).

Method 2. Add  ?tinyInt1isBit=false  to jdbcURL  , the default is true

As shown

mybatis-generator reverse engineering to generate boolean field solution

Both can, and finally, status and is_comment are converted to byte type, available!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325296794&siteId=291194637