HHH-9286 - Add CustomType implements ProcedureParameterNamedBinder

This commit is contained in:
Andrea Boriero 2016-01-25 20:53:35 +00:00
parent 9567d9af76
commit a339ebd8a9
1 changed files with 23 additions and 1 deletions

View File

@ -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"
);
}
}
}