Skip to content

Commit b2ed4c5

Browse files
committed
work around a design problem (possibly a bug) affecting hibernate-vector
1 parent 15a4b3d commit b2ed4c5

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ public BasicArrayType(BasicType<E> baseDescriptor, JdbcType arrayJdbcType, JavaT
3232
super( arrayJdbcType, arrayTypeDescriptor );
3333
this.baseDescriptor = baseDescriptor;
3434
this.name = determineArrayTypeName( baseDescriptor );
35-
this.arrayTypeDescriptor = (AbstractArrayJavaType<T, ?>) arrayTypeDescriptor;
35+
this.arrayTypeDescriptor =
36+
arrayTypeDescriptor instanceof AbstractArrayJavaType<T, ?> arrayJavaType
37+
? arrayJavaType
38+
// this only happens with contributions from hibernate-vector
39+
// because it passes in a PrimitiveByteArrayJavaType which is
40+
// not an AbstractArrayJavaType (this might be a bug)
41+
: null;
3642
}
3743

3844
static String determineElementTypeName(BasicType<?> baseDescriptor) {
@@ -91,7 +97,11 @@ public int hashCode() {
9197

9298
@Override
9399
public boolean isEqual(Object one, Object another) {
94-
if ( one == another ) {
100+
if ( arrayTypeDescriptor == null ) {
101+
// for hibernate-vector
102+
return super.isEqual( one, another );
103+
}
104+
else if ( one == another ) {
95105
return true;
96106
}
97107
else if ( one == null || another == null ) {
@@ -104,6 +114,8 @@ else if ( one == null || another == null ) {
104114

105115
@Override
106116
public Object deepCopy(Object value, SessionFactoryImplementor factory) {
107-
return arrayTypeDescriptor.deepCopy( value );
117+
return arrayTypeDescriptor == null
118+
? super.deepCopy( value, factory ) // for hibernate-vector
119+
: arrayTypeDescriptor.deepCopy( value );
108120
}
109121
}

0 commit comments

Comments
 (0)