How to execute a stored procedure in playframework 1.2.4 using JPA?

227 views Asked by At

How to execute a stored procedure in playframework 1.2.4 using JPA?and the back end is mysqldatabase.I want to execute the stored procedure in play 1.2.4.I am new to play framework.

1

There are 1 answers

0
Neilos On

This may or may not be useful but here is how I do it using Spring JDBC. First create some procedure:

DELIMITER //
DROP PROCEDURE IF EXISTS my_procedure //
CREATE PROCEDURE my_procedure(    
    OUT id INT,
    OUT name VARCHAR(70),
    OUT other VARCHAR(1024)
)
BEGIN
    SELECT
        ...
    FROM
        ...
    GROUP BY
        ...
END //
DELIMITER ;

Then execute query using Spring JDBC RowMappers:

JdbcTemplate jt = new JdbcTemplate(DB.getDataSource(DB_User));
List<Details> list = jt.query(MyProcedureRowMapper.QUERY, 
    new Object[] {}, new MyProcedureRowMapper());

Where the query looks like this:

public static final String Query = "{ CALL my_procedure(@id, @name, @other) }";