【发布时间】:2014-04-21 20:46:57
【问题描述】:
我想在运行我的 java 程序时更新我的所有 SP(如果这不是好的做法也没关系)。 由于我使用的是 Hibernate 4.3.2.Final,因此我试图避免为 MySQL 编写自己的 SQL 执行器。 所以我试图在我的 hibernate.cfg.xml 中使用 hibernate.hbm2ddl.import_files。 它获取脚本,但无法解析它。我试过了
<property name="hibernate.hbm2ddl.import_files">/Database/stored_procedures/load.sql</property>
<property name="hibernate.hbm2ddl.import_files_sql_extractor">org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor</property>
但我明白了
org.hibernate.tool.hbm2ddl.ImportScriptException: Error during statement execution (file: '/Database/stored_procedures/load.sql'): DELIMITER $$
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER $$
SP sql 文件在 MySQL 上运行良好(尝试了很多次),类似于:
DROP PROCEDURE IF EXISTS ebull.`load_friends`;
DELIMITER $$
CREATE PROCEDURE ebull.`load_friends`(
IN transactionId BIGINT,
IN chunk INT
)
BEGIN
...sql queries and stuff....
END
$$
DELIMITER ;
我认为分隔符有问题,但我不知道如何避免它们,因为它是一个存储过程定义。 我开始认为这是不可能的。有什么想法吗?
【问题讨论】:
标签: mysql sql hibernate file import