When I define an Entity with
@Column(name ="MYCOLLUMN", columnDefinition = "char")
And then try to overwrite the Typedescriptor like this:
{noformat} public static class CustomOracleDialect extends Oracle12cDialect {
private static final CharLikeVarchar INSTANCE = new CharLikeVarchar();
@Override protected SqlTypeDescriptor getSqlTypeDescriptorOverride(final int sqlCode) { switch (sqlCode) { case Types.CHAR: return INSTANCE; default: return super.getSqlTypeDescriptorOverride(sqlCode); } } } {noformat}
My CharLikeVarChar typeDescriptor will not be used instead it will use the VarcharType Descriptor. This means I have to overwrite VARCHAR instead of CHAR which does not seem correct.
{noformat} public static class CustomOracleDialect extends Oracle12cDialect {
private static final CharLikeVarchar INSTANCE = new CharLikeVarchar();
@Override protected SqlTypeDescriptor getSqlTypeDescriptorOverride(final int sqlCode) { switch (sqlCode) { case Types.VARCHAR: return INSTANCE; default: return super.getSqlTypeDescriptorOverride(sqlCode); } } } {noformat}
Maybe someone can explain to me why it is that way. We have the problem, that our Legacy Oracle DB uses a lot of Char fields. We want to use Oracles setFixedChar to circumvent the whitespace problems we are facing. But because Hibernate ignores the columnDefinition Field we had to get creative with our solutiion and had to work around hibernate a lot which should not be neccesary, |
|