我有两个表:td
和last_td
。我写了这个函数:
CREATE OR REPLACE FUNCTION f_find_last_td()
RETURNS trigger AS
$BODY$
DECLARE
BEGIN
delete from last_td;
insert into last_td
select
t1.name,
t1.max,
t2.due_date,
t2.fixed_rate,
t2.unit_price,
t2.reading_time
from (select
t2.name,
max(t2.reading_date)
from td t2
where
t2.reading_date > now()
group by t2.name) t1,
td t2
where
t1.name = t2.name
and t1.max = t2.reading_date;
commit;
RETURN NEW;
END;
$BODY$
LANGUAGE plpgsql
用作触发器,如下所示:
CREATE TRIGGER tr_find_last_td
AFTER INSERT OR UPDATE
ON td
EXECUTE PROCEDURE f_find_last_td();
我在Wildfly 10.1.0.Final上使用hibernate 5.0.10.Final运行Java应用程序<property name="hibernate.hbm2ddl.auto" value="validate"/>
但现在每次hibernate尝试将数据插入td
时,都会输出此错误:
Hint: Use a BEGIN block with an EXCEPTION clause instead.
Where: PL/pgSQL function f_find_last_td() line 25 at SQL statement
14:21:00,425 INFO [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (EJB default - 9) HHH000010: On release of batch it still contained JDBC statements
当然我可以添加EXCEPTION
来捕获它,但为什么我会收到此错误?