Drop TypedParameterValue handling for stored procedures.
Hibernate resolved https://github.com/hibernate/hibernate-orm/pull/5438, allowing us to no longer implement special handling. Closes #2902 Original pull request #2933
This commit is contained in:
committed by
Jens Schauder
parent
879d66279d
commit
9dbd41e377
@@ -68,4 +68,21 @@ class HibernateJpaParametersParameterAccessor extends JpaParametersParameterAcce
|
||||
}
|
||||
return new TypedParameterValue(type, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to potentially unwrap {@link TypedParameterValue}s. For certain operations, Hibernate doesn't
|
||||
* properly support them, so we must unwrap them before passing through.
|
||||
*
|
||||
* @param extractedValue
|
||||
* @return the value behind a {@link TypedParameterValue}
|
||||
*/
|
||||
@Override
|
||||
public Object potentiallyUnwrap(Object extractedValue) {
|
||||
|
||||
if (extractedValue instanceof TypedParameterValue) {
|
||||
return ((TypedParameterValue) extractedValue).getValue();
|
||||
} else {
|
||||
return extractedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,17 @@ public class JpaParametersParameterAccessor extends ParametersParameterAccessor
|
||||
return super.getValue(parameter.getIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to potentially unwrap certain provider-specific types. For general JPA, there are none, so it's a pass-through.
|
||||
*
|
||||
* @param extractedValue
|
||||
* @return the same value passed in
|
||||
*/
|
||||
@Nullable
|
||||
public Object potentiallyUnwrap(Object extractedValue) {
|
||||
return extractedValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getValues() {
|
||||
return super.getValues();
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.jpa.repository.query;
|
||||
|
||||
import static org.springframework.data.jpa.repository.query.QueryParameterSetter.ErrorHandling.LENIENT;
|
||||
import static org.springframework.data.jpa.repository.query.QueryParameterSetter.ErrorHandling.*;
|
||||
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.Collections;
|
||||
@@ -33,7 +33,6 @@ import javax.persistence.criteria.ParameterExpression;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.jpa.TypedParameterValue;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -87,16 +86,10 @@ interface QueryParameterSetter {
|
||||
|
||||
final Object value;
|
||||
|
||||
// TODO: When https://github.com/hibernate/hibernate-orm/pull/5438 is merged we should be able to drop this.
|
||||
if (query.getQuery() instanceof StoredProcedureQuery) {
|
||||
|
||||
Object extractedValue = valueExtractor.apply(accessor);
|
||||
|
||||
if (extractedValue instanceof TypedParameterValue) {
|
||||
value = ((TypedParameterValue) extractedValue).getValue();
|
||||
} else {
|
||||
value = extractedValue;
|
||||
}
|
||||
value = accessor.potentiallyUnwrap(extractedValue);
|
||||
} else {
|
||||
value = valueExtractor.apply(accessor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user