Skip to content

Commit 64f6ea7

Browse files
Sannebrmeyer
authored andcommitted
HHH-8950 Avoid repeated array allocation for sqlTypes
1 parent b840a9e commit 64f6ea7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

hibernate-core/src/main/java/org/hibernate/type/AbstractStandardBasicType.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ public abstract class AbstractStandardBasicType<T>
6464
// by DynamicParameterizedTypes.
6565
private SqlTypeDescriptor sqlTypeDescriptor;
6666
private JavaTypeDescriptor<T> javaTypeDescriptor;
67+
// sqlTypes need always to be in sync with sqlTypeDescriptor
68+
private int[] sqlTypes;
6769

6870
public AbstractStandardBasicType(SqlTypeDescriptor sqlTypeDescriptor, JavaTypeDescriptor<T> javaTypeDescriptor) {
6971
this.sqlTypeDescriptor = sqlTypeDescriptor;
72+
this.sqlTypes = new int[] { sqlTypeDescriptor.getSqlType() };
7073
this.javaTypeDescriptor = javaTypeDescriptor;
7174
}
7275

@@ -141,9 +144,10 @@ public final void setJavaTypeDescriptor( JavaTypeDescriptor<T> javaTypeDescripto
141144
public final SqlTypeDescriptor getSqlTypeDescriptor() {
142145
return sqlTypeDescriptor;
143146
}
144-
147+
145148
public final void setSqlTypeDescriptor( SqlTypeDescriptor sqlTypeDescriptor ) {
146149
this.sqlTypeDescriptor = sqlTypeDescriptor;
150+
this.sqlTypes = new int[] { sqlTypeDescriptor.getSqlType() };
147151
}
148152

149153
public final Class getReturnedClass() {
@@ -155,7 +159,7 @@ public final int getColumnSpan(Mapping mapping) throws MappingException {
155159
}
156160

157161
public final int[] sqlTypes(Mapping mapping) throws MappingException {
158-
return new int[] { sqlTypeDescriptor.getSqlType() };
162+
return sqlTypes;
159163
}
160164

161165
@Override

0 commit comments

Comments
 (0)