I have following Mysql stored procedure with only OUT parameters, How I can call this stored procedure through hibernate in with only OUT Parameters?
CREATE PROCEDURE DBNAME.getStatistics (OUT A BIGINT UNSIGNED, OUT B BIGINT UNSIGNED, OUT C BIGINT UNSIGNED)
BEGIN
SELECT count(*) into A from DBNAME.Table1 where id =0;
SELECT count(*) into B from DBNAME.Table2 where id>0 and id<4;
SELECT count(*) into C from DBNAME.Table3 where id>4;
END
EDIT
Following code I used in java to test the call of MySQL stored procedure (with only OUT Parameters) through hibernate(Java):
Session session = HibernateUtil.getSessionFactory().openSession();
Connection connection = session.connection();
CallableStatement callable = null;
try {
callable = connection.prepareCall("{Call DBNAME.getStatistics(?,?,?)}");
// three ?,?,? means three OUT parameter.
// If any parameters is IN type of
// Lets say the first one then use : callable.setInt(1, 10);
callable.registerOutParameter(1, Types.BIGINT);
callable.registerOutParameter(2, Types.BIGINT);
callable.registerOutParameter(3, Types.BIGINT);
callable.executeUpdate();
int value1 = callable.getInt(1);
int value2 = callable.getInt(2);
int value3 = callable.getInt(3);
System.out.println(value1);
System.out.println(value2);
System.out.println(value3);
} catch (SQLException e) {
e.printStackTrace();
}