diff --git a/hibernate-core/src/main/java/org/hibernate/type/AbstractStandardBasicType.java b/hibernate-core/src/main/java/org/hibernate/type/AbstractStandardBasicType.java index 1252f2fb0d..7a85f079c1 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/AbstractStandardBasicType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/AbstractStandardBasicType.java @@ -62,9 +62,12 @@ public abstract class AbstractStandardBasicType // by DynamicParameterizedTypes. private SqlTypeDescriptor sqlTypeDescriptor; private JavaTypeDescriptor javaTypeDescriptor; + // sqlTypes need always to be in sync with sqlTypeDescriptor + private int[] sqlTypes; public AbstractStandardBasicType(SqlTypeDescriptor sqlTypeDescriptor, JavaTypeDescriptor javaTypeDescriptor) { this.sqlTypeDescriptor = sqlTypeDescriptor; + this.sqlTypes = new int[] { sqlTypeDescriptor.getSqlType() }; this.javaTypeDescriptor = javaTypeDescriptor; } @@ -139,9 +142,10 @@ public abstract class AbstractStandardBasicType public final SqlTypeDescriptor getSqlTypeDescriptor() { return sqlTypeDescriptor; } - + public final void setSqlTypeDescriptor( SqlTypeDescriptor sqlTypeDescriptor ) { this.sqlTypeDescriptor = sqlTypeDescriptor; + this.sqlTypes = new int[] { sqlTypeDescriptor.getSqlType() }; } public final Class getReturnedClass() { @@ -153,7 +157,7 @@ public abstract class AbstractStandardBasicType } public final int[] sqlTypes(Mapping mapping) throws MappingException { - return new int[] { sqlTypeDescriptor.getSqlType() }; + return sqlTypes; } @Override