I’m having an issue where a JPAentity I’m importing from another library has a field that’s hardcoded to be columnDefinition = TEXT
but I’d like that field to be LONGTEXT in the db. I am not allowed to edit to the JPAentity itself, nor can I just make my own. Is there a way to force this via a custom dialect somehow?
What I tried:
public class CustomSQLDialect extends MySQL5Dialect {
public CustomSQLDialect() {
super();
registerColumnType(Types.VARCHAR, "LONGTEXT");
registerColumnType(Types.LONGNVARCHAR, "LONGTEXT");
}
@Override
public String getTypeName(int code, long length, int precision, int scale) throws HibernateException {
if (code == Types.VARCHAR || code == Types.LONGNVARCHAR) {
return "LONGTEXT";
}
return super.getTypeName(code, length, precision, scale);
}
@Override
public SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
if (sqlCode == Types.VARCHAR || sqlCode == Types.LONGNVARCHAR) {
return LongVarcharTypeDescriptor.INSTANCE;
}
return super.getSqlTypeDescriptorOverride(sqlCode);
}
}
New contributor
neongenesisevangelicals is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.