From cbe00ce2536963f82cafd30275ced5399ede78c9 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 20 Jan 2016 16:31:30 +0000 Subject: [PATCH] HHH-9286 - Add ProcedureParameterNamedBinder interface --- .../type/ProcedureParameterNamedBinder.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 hibernate-core/src/main/java/org/hibernate/type/ProcedureParameterNamedBinder.java diff --git a/hibernate-core/src/main/java/org/hibernate/type/ProcedureParameterNamedBinder.java b/hibernate-core/src/main/java/org/hibernate/type/ProcedureParameterNamedBinder.java new file mode 100644 index 0000000000..262f06f7de --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/type/ProcedureParameterNamedBinder.java @@ -0,0 +1,45 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.type; + +import java.sql.CallableStatement; +import java.sql.SQLException; + +import org.hibernate.HibernateException; +import org.hibernate.engine.spi.SessionImplementor; + +/** + * Optional {@link Type} contract for implementations enabled + * to set store procedure OUT/INOUT parameters values by name. + * + * @author Andrea Boriero + */ +public interface ProcedureParameterNamedBinder { + + /** + * Can the given instance of this type actually set the parameter value by name + * + * @return {@code true} indicates that @{link #nullSafeSet} calls will not fail + */ + public boolean canDoSetting(); + + /** + * Bind a value to the JDBC prepared statement, ignoring some columns as dictated by the 'settable' parameter. + * Implementors should handle the possibility of null values. + * Does not support multi-column type + * + * @param statement The CallableStatement to which to bind + * @param value the object to write + * @param name parameter bind name + * @param session The originating session + * + * @throws HibernateException An error from Hibernate + * @throws SQLException An error from the JDBC driver + */ + public void nullSafeSet(CallableStatement statement, Object value, String name, SessionImplementor session) + throws SQLException; +}