HHH-9286 - Add CustomType implements ProcedureParameterExtractionAware
This commit is contained in:
parent
a339ebd8a9
commit
5e5ae9dacb
|
@ -772,8 +772,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
|
||||
|
|
|
@ -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"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.hibernate.engine.spi.SessionImplementor;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface ProcedureParameterExtractionAware<T> extends Type {
|
||||
public interface ProcedureParameterExtractionAware<T> {
|
||||
/**
|
||||
* Can the given instance of this type actually perform the parameter value extractions?
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue