Pre-history: I get JDBCExceptionReporter data exception: string data, right truncation
exception on update of entities.
I have found that this means, the data is too big for the specified varchar
.
In the service.xml
the column is specified like:
<column name="message" type="String"/>
I have found in Liferay's source code for ServiceBuilder
this fragment:
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");
}
}
Now my question is, how can I define the max-length
for my columns?