I have a MySQL StoredProcedure(EmployeeAbsentReport Procedure)for Given Two Dateranges. which is Successfully running on MySql Commandprompt. How can I run this Stored Procedure using Hibernate
Procedure:
Code:
DELIMITER $$
DROP PROCEDURE IF EXISTS `AbsentReportproc`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `AbsentReportproc`(IN _fromdate DATETIME, IN _todate DATETIME)
BEGIN
CREATE TEMPORARY TABLE daterange25 (dte DATE);
SET @counter := 0;
WHILE (@counter < DATEDIFF(DATE(_todate), DATE(_fromdate))) DO
INSERT INTO daterange25 VALUES (DATE_ADD(_fromdate, INTERVAL @counter:=@counter + 1 DAY));
END WHILE;
SELECT tp.EMPCODE,tp.NAME,tp.DEPARTMENT, Group_Concat(d.dte order by d.dte SEPARATOR '\n')AbsentDate, COUNT(tp.EMPCODE) Totalnoofabsentdates
FROM Master tp
JOIN daterange25 d
LEFT JOIN Transactions tpt ON (tp.EMPCODE = tpt.empcode) AND DATE(S_DateTime) = d.dte
WHERE tpt.empcode IS NULL
GROUP BY tp.EMPCODE;
DROP TABLE daterange25;
END$$
DELIMITER ;
how to call a MSQL Stored Procedure using Hibernate with joins(Including a Temporary Table)and Hibernate Mapping Files, sql-query in XML mapping file?