From a339ebd8a9e6ece8cc32eae06fe46589b0c12052 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Mon, 25 Jan 2016 20:53:35 +0000 Subject: [PATCH] HHH-9286 - Add CustomType implements ProcedureParameterNamedBinder --- .../java/org/hibernate/type/CustomType.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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 d90ff10ecb..67709ff6ba 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/CustomType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/CustomType.java @@ -7,6 +7,7 @@ package org.hibernate.type; import java.io.Serializable; +import java.sql.CallableStatement; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -39,7 +40,7 @@ import org.dom4j.Node; */ public class CustomType extends AbstractType - implements IdentifierType, DiscriminatorType, VersionType, BasicType, StringRepresentableType { + implements IdentifierType, DiscriminatorType, VersionType, BasicType, StringRepresentableType, ProcedureParameterNamedBinder { private final UserType userType; private final String name; @@ -250,4 +251,25 @@ public class CustomType ) ); } + + @Override + public boolean canDoSetting() { + if ( ProcedureParameterNamedBinder.class.isInstance( userType ) ) { + return ((ProcedureParameterNamedBinder) userType).canDoSetting(); + } + return false; + } + + @Override + public void nullSafeSet( + CallableStatement statement, Object value, String name, SessionImplementor session) throws SQLException { + if ( canDoSetting() ) { + ((ProcedureParameterNamedBinder) userType).nullSafeSet( statement, value, name, session ); + } + else { + throw new UnsupportedOperationException( + "Type [" + userType + "] does support parameter binding by name" + ); + } + } }