Skip to content

Commit d9876d6

Browse files
gavinkingmbellade
authored andcommitted
implement equals() / hashCode() for NativeQueryConstructorTransformer
to help the query interpretation cache
1 parent aefc2d1 commit d9876d6

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

hibernate-core/src/main/java/org/hibernate/jpa/spi/NativeQueryConstructorTransformer.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
public class NativeQueryConstructorTransformer<T> implements TupleTransformer<T> {
2121

2222
private final Class<T> resultClass;
23-
private Constructor<T> constructor;
23+
private transient Constructor<T> constructor;
2424

2525
private Constructor<T> constructor(Object[] elements) {
2626
if ( constructor == null ) {
@@ -71,4 +71,21 @@ public T transformTuple(Object[] tuple, String[] aliases) {
7171
throw new InstantiationException( "Cannot instantiate query result type", resultClass, e );
7272
}
7373
}
74+
75+
@Override
76+
public boolean equals(Object obj) {
77+
if ( this == obj ) {
78+
return true;
79+
}
80+
if ( obj == null || getClass() != obj.getClass() ) {
81+
return false;
82+
}
83+
final NativeQueryConstructorTransformer<?> that = (NativeQueryConstructorTransformer<?>) obj;
84+
return resultClass.equals( that.resultClass );
85+
}
86+
87+
@Override
88+
public int hashCode() {
89+
return resultClass.hashCode();
90+
}
7491
}

0 commit comments

Comments
 (0)