以下是对应的Mysql存储过程,我在mysql qurey browser中运行了,很正常 DELIMITER $$DROP PROCEDURE IF EXISTS `qfy`.`HomeMsg_getMsg` $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `HomeMsg_getMsg`(in homeN integer) begin declare hmsgcount integer; select count(hmsgID) into hmsgcount from homeMsg where homeId=homeN and DATEDIFF (CURRENT_DATE (),date(hmsgDate))=0; if hmsgcount=0 then select hmsgMessage,hmsgUrl,hmsgTitle from homeMsg where homeID=homeN and hmsgDate=(select max(hmsgDate) from homeMsg where homeID=homeN and hmsgDate<CURRENT_DATE ()); else select hmsgMessage,hmsgUrl,hmsgTitle from homeMsg where homeId=homeN and DATEDIFF (CURRENT_DATE (),date(hmsgDate))=0; end if; end $$DELIMITER ;
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1244下载上面的MySQLDialect.java 文件Hibernate reports the following when attempting to use a stored procedure to implement load() or getNamedQuery:[java] Exception in thread "main" java.lang.UnsupportedOperationException: org.hibernate.dialect.MySQLDialect does not support resultsets via stored procedures.The MySQLDialiect file needs to be modified to reflect the MySQL5 capability of issuing stored procedures. The semantics of stored procedures in MySQL is most similar to that in SQLServer, so copying the relevent sections of the SQLServerDialect ought to be sufficient. I tried that and it seemed to work. Modified MySQLDialect is attached
如果不行,Mysql如何得到结果集
还有用到MySQLDialect的那段代码
真晕死
这都不贴出来怎么看问题啊
DELIMITER $$DROP PROCEDURE IF EXISTS `qfy`.`HomeMsg_getMsg` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `HomeMsg_getMsg`(in homeN integer)
begin
declare hmsgcount integer; select count(hmsgID) into hmsgcount
from homeMsg where homeId=homeN
and DATEDIFF (CURRENT_DATE (),date(hmsgDate))=0; if hmsgcount=0 then
select hmsgMessage,hmsgUrl,hmsgTitle from homeMsg where homeID=homeN
and hmsgDate=(select max(hmsgDate) from homeMsg where homeID=homeN and hmsgDate<CURRENT_DATE ());
else
select hmsgMessage,hmsgUrl,hmsgTitle
from homeMsg where homeId=homeN
and DATEDIFF (CURRENT_DATE (),date(hmsgDate))=0;
end if;
end $$DELIMITER ;