病史:我得到JDBCExceptionReporter data exception: string data, right truncation
異常更新實體。如何使用service.xml或Service Builder設置字符串列的大小?
我發現這意味着,對於指定的varchar
,數據太大。
在service.xml
柱子等確定:
<column name="message" type="String"/>
我在Liferay的源代碼中發現了ServiceBuilder
這個片段:
else if (colType.equals("String")) {
Map<String, String> hints = ModelHintsUtil.getHints(
_packagePath + ".model." + entity.getName(), colName);
int maxLength = 75;
if (hints != null) {
maxLength = GetterUtil.getInteger(
hints.get("max-length"), maxLength);
}
if (col.isLocalized()) {
maxLength = 4000;
}
if (maxLength < 4000) {
sb.append("VARCHAR(" + maxLength + ")");
}
else if (maxLength == 4000) {
sb.append("STRING");
}
else if (maxLength > 4000) {
sb.append("TEXT");
}
}
現在的問題是,我怎麼能定義max-length
爲我的專欄?