Example usage for org.springframework.jdbc.core.simple SimpleJdbcCall executeFunction

List of usage examples for org.springframework.jdbc.core.simple SimpleJdbcCall executeFunction

Introduction

In this page you can find the example usage for org.springframework.jdbc.core.simple SimpleJdbcCall executeFunction.

Prototype

@Override
    @SuppressWarnings("unchecked")
    public <T> T executeFunction(Class<T> returnType, SqlParameterSource args) 

Source Link

Usage

From source file:org.springframework.jdbc.core.simple.SimpleJdbcCallTests.java

public void testAddInvoiceFuncWithoutMetaDataUsingMapParamSource() throws Exception {
    final int amount = 1103;
    final int custid = 3;

    initializeAddInvoiceWithoutMetaData(true);

    replay();//from  ww  w.j  a va2s .c  o m

    SimpleJdbcCall adder = new SimpleJdbcCall(mockDataSource).withFunctionName("add_invoice");
    adder.declareParameters(new SqlOutParameter("return", Types.INTEGER),
            new SqlParameter("amount", Types.INTEGER), new SqlParameter("custid", Types.INTEGER));
    Number newId = adder.executeFunction(Number.class,
            new MapSqlParameterSource().addValue("amount", amount).addValue("custid", custid));
    assertEquals(4, newId.intValue());
}

From source file:org.springframework.jdbc.core.simple.SimpleJdbcCallTests.java

public void testAddInvoiceFuncWithMetaDataUsingMapParamSource() throws Exception {
    final int amount = 1103;
    final int custid = 3;

    MockControl ctrlResultSet = initializeAddInvoiceWithMetaData(true);

    ctrlResultSet.replay();//from  www  .j  ava2 s.  co m
    replay();

    SimpleJdbcCall adder = new SimpleJdbcCall(mockDataSource).withFunctionName("add_invoice");
    Number newId = adder.executeFunction(Number.class,
            new MapSqlParameterSource().addValue("amount", amount).addValue("custid", custid));
    assertEquals(4, newId.intValue());

    ctrlResultSet.verify();
}