Skip to content

Commit d35c060

Browse files
committed
implement equals() / hashCode() for NativeQueryConstructorTransformer
to help the query interpretation cache
1 parent 199269a commit d35c060

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
public class NativeQueryConstructorTransformer<T> implements TupleTransformer<T> {
2525

2626
private final Class<T> resultClass;
27-
private Constructor<T> constructor;
27+
private transient Constructor<T> constructor;
2828

2929
private Constructor<T> constructor(Object[] elements) {
3030
if ( constructor == null ) {
@@ -75,4 +75,16 @@ public T transformTuple(Object[] tuple, String[] aliases) {
7575
throw new InstantiationException( "Cannot instantiate query result type", resultClass, e );
7676
}
7777
}
78+
79+
@Override
80+
public boolean equals(Object obj) {
81+
return obj instanceof NativeQueryConstructorTransformer<?> that
82+
&& this.resultClass == that.resultClass;
83+
// should be safe to ignore the cached constructor here
84+
}
85+
86+
@Override
87+
public int hashCode() {
88+
return resultClass.hashCode();
89+
}
7890
}

0 commit comments

Comments
 (0)