我无法使用hibernate创建临时表这里是我的代码
getSession().beginTransaction();
String queryString1 = "CREATE TEMPORARY TABLE sage_temp_table(CRMID VARCHAR(60),POPAmountPaid DECIMAL(14,2)) ";
getSession().createSQLQuery(queryString1).executeUpdate();
getSession().flush();
String queryString2 = "INSERT INTO sage_temp_table(CRMID,POPAmountPaid) SELECT CRMID,POPAmountPaid FROM sage_payments WHERE sage_payments.`CRMID` REGEXP \"^[0-9]+$\" AND"
+ " sage_payments.POPPaidDate NOT LIKE \"%0000-00-00 00%\" AND sage_payments.POPPaidDate IS NOT NULL AND sage_payments.POPAmountPaid IS NOT NULL";
getSession().createSQLQuery(queryString2).executeUpdate();
getSession().beginTransaction().commit();
在日志中它显示命令正在运行,但是当我从表中选择内容时,它表示表sage_temp_table不存在因此不会创建并且不会给出任何错误。这是日志
04:00:04,549 INFO [STDOUT] Hibernate: CREATE TEMPORARY TABLE sage_temp_table(CRMID VARCHAR(60),POPAmountPaid DECIMAL(14,2))
04:00:17,463 INFO [STDOUT] Hibernate: INSERT INTO sage_temp_table(CRMID,POPAmountPaid) SELECT CRMID,POPAmountPaid FROM sage_payments WHERE sage_payments.`CRMID` REGEXP "^[0-9]+$" AND sage_payments.POPPaidDate NOT LIKE "%0000-00-00 00%" AND sage_payments.POPPaidDate IS NOT NULL AND sage_payments.POPAmountPaid IS NOT NULL
此处还有一个案例,当我从queryString1表中删除TEMPORARY时,会创建并插入。 请告诉我它有什么问题?