Search in sources :

Example 6 with ParameterRegistrationImplementor

use of org.hibernate.procedure.spi.ParameterRegistrationImplementor in project hibernate-orm by hibernate.

the class StandardCallableStatementSupport method renderCallableStatement.

@Override
public String renderCallableStatement(String procedureName, ParameterStrategy parameterStrategy, List<ParameterRegistrationImplementor<?>> parameterRegistrations, SharedSessionContractImplementor session) {
    final StringBuilder buffer = new StringBuilder().append("{call ").append(procedureName).append("(");
    String sep = "";
    for (ParameterRegistrationImplementor parameter : parameterRegistrations) {
        if (parameter == null) {
            throw new QueryException("Parameter registrations had gaps");
        }
        if (parameter.getMode() == ParameterMode.REF_CURSOR) {
            verifyRefCursorSupport(session.getJdbcServices().getJdbcEnvironment().getDialect());
            buffer.append(sep).append("?");
            sep = ",";
        } else {
            for (int i = 0; i < parameter.getSqlTypes().length; i++) {
                buffer.append(sep).append("?");
                sep = ",";
            }
        }
    }
    return buffer.append(")}").toString();
}
Also used : QueryException(org.hibernate.QueryException) ParameterRegistrationImplementor(org.hibernate.procedure.spi.ParameterRegistrationImplementor)

Aggregations

ParameterRegistrationImplementor (org.hibernate.procedure.spi.ParameterRegistrationImplementor)6 SQLException (java.sql.SQLException)2 CallableStatement (java.sql.CallableStatement)1 HibernateException (org.hibernate.HibernateException)1 QueryException (org.hibernate.QueryException)1