diff --git a/hibernate-core/src/main/java/org/hibernate/type/ComponentType.java b/hibernate-core/src/main/java/org/hibernate/type/ComponentType.java index b73c20933f..6ed8bd877c 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/ComponentType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/ComponentType.java @@ -771,8 +771,12 @@ public class ComponentType extends AbstractType implements CompositeType, Proced boolean notNull = false; for ( int i = 0; i < propertySpan; i++ ) { // we know this cast is safe from canDoExtraction - final ProcedureParameterExtractionAware propertyType = (ProcedureParameterExtractionAware) propertyTypes[i]; - final Object value = propertyType.extract( statement, currentIndex, session ); + final Type propertyType = propertyTypes[i]; + final Object value = ((ProcedureParameterExtractionAware) propertyType).extract( + statement, + currentIndex, + session + ); if ( value == null ) { if ( isKey ) { return null; //different nullability rules for pk/fk diff --git a/hibernate-core/src/main/java/org/hibernate/type/CustomType.java b/hibernate-core/src/main/java/org/hibernate/type/CustomType.java index 67709ff6ba..be35e23033 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/CustomType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/CustomType.java @@ -40,7 +40,7 @@ import org.dom4j.Node; */ public class CustomType extends AbstractType - implements IdentifierType, DiscriminatorType, VersionType, BasicType, StringRepresentableType, ProcedureParameterNamedBinder { + implements IdentifierType, DiscriminatorType, VersionType, BasicType, StringRepresentableType, ProcedureParameterNamedBinder, ProcedureParameterExtractionAware { private final UserType userType; private final String name; @@ -272,4 +272,37 @@ public class CustomType ); } } + + @Override + public boolean canDoExtraction() { + if ( ProcedureParameterExtractionAware.class.isInstance( userType ) ) { + return ((ProcedureParameterExtractionAware) userType).canDoExtraction(); + } + return false; + } + + @Override + public Object extract(CallableStatement statement, int startIndex, SessionImplementor session) throws SQLException { + if ( canDoExtraction() ) { + return ((ProcedureParameterExtractionAware) userType).extract( statement, startIndex, session ); + } + else { + throw new UnsupportedOperationException( + "Type [" + userType + "] does support parameter value extraction" + ); + } + } + + @Override + public Object extract(CallableStatement statement, String[] paramNames, SessionImplementor session) + throws SQLException { + if ( canDoExtraction() ) { + return ((ProcedureParameterExtractionAware) userType).extract( statement, paramNames, session ); + } + else { + throw new UnsupportedOperationException( + "Type [" + userType + "] does support parameter value extraction" + ); + } + } } diff --git a/hibernate-core/src/main/java/org/hibernate/type/ProcedureParameterExtractionAware.java b/hibernate-core/src/main/java/org/hibernate/type/ProcedureParameterExtractionAware.java index 6eff4650da..5a1e5a27e6 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/ProcedureParameterExtractionAware.java +++ b/hibernate-core/src/main/java/org/hibernate/type/ProcedureParameterExtractionAware.java @@ -17,7 +17,7 @@ import org.hibernate.engine.spi.SessionImplementor; * * @author Steve Ebersole */ -public interface ProcedureParameterExtractionAware extends Type { +public interface ProcedureParameterExtractionAware { /** * Can the given instance of this type actually perform the parameter value extractions? *