The CallableStatement interface used to execute SQL stored procedures. The JDBC API provides a stored procedure SQL escape syntax that allows stored procedures to be called in a standard way for all RDBMSs. This escape syntax has one form that includes a result parameter and one that does not. If used, the result parameter must be registered as an OUT parameter. The other parameters can be used for input, output or both. Parameters are referred to sequentially, by number, with the first parameter being 1.
IN parameter values are set using the set methods inherited from PreparedStatement. The type of all OUT parameters must be registered prior to executing the stored procedure; their values are retrieved after execution via the get methods provided here.
In the preceding example in_user _id and out_username are the input and output parameters in the procedure respectively. Please also be aware that you can not use the Hibernate to call a procedure if there is an output parameter other than a result set.
If the resultSet has multiple records, you have to go through the each record.
Otherwise, you can just use callableStatement to fetch the value for the required column.
String username = callableStatement.getLong("out_ username ");