We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
49中Dao
Byte --> TINYINT Integer --> INT Long --> BIGINT
问题是为什么Short对应的也是 TINYINT? 建议换成 SMALLINT 或者 MEDIUMINT
The text was updated successfully, but these errors were encountered:
哇,这么细腻,有必要吗?
Sorry, something went wrong.
细致一点没啥不好哈~ 因为我一个Bean里面用呢Short,结果写入的时候报错,too long了,所以才发现了这个问题~
如果你要限制特殊的大小,你可以
@Column("n") @ColDefine(type=ColType.INT, width=2) // 相当于 INT(2) private short num;
对于 Mysql 的逻辑,参加如下代码:
@Override protected String evalFieldType(MappingField mf) { if (mf.getCustomDbType() != null) return mf.getCustomDbType(); // Mysql 的精度是按照 bit if (mf.getColumnType() == ColType.INT) { int width = mf.getWidth(); if (width <= 0) return "INT(32)"; else if (width <= 4) { return "TINYINT(" + (width * 4) + ")"; } else if (width <= 8) { return "INT(" + (width * 4) + ")"; } return "BIGINT(" + (width * 4) + ")"; } if (mf.getColumnType() == ColType.BINARY) { return "MediumBlob"; //默认用16M的应该可以了吧? } // 其它的参照默认字段规则 ... return super.evalFieldType(mf); }
一开始我也是用@Coldefine来搞这个问题,总感觉能写一行的,干嘛要写2行呢,框架就应该是去做脏活的嘛。既然都写MYSQL的类了,也是想对MYSQL有更好的支持,为什么就不能更加的细分呢??
上面的代码也只能知道是CloType.INT,有办法知道BEAN中字段的类型吗?? 可能的话,就根据字段类型来区分对待,细分一点。
Fix issue #594
d61593e
zozoh
No branches or pull requests
49中Dao
Byte --> TINYINT
Integer --> INT
Long --> BIGINT
问题是为什么Short对应的也是 TINYINT?
建议换成 SMALLINT 或者 MEDIUMINT
The text was updated successfully, but these errors were encountered: