日期:2014-05-16  浏览次数:20695 次

Postgresql-7.3.1版本中遇到的trncate问题!
Hibernate中使用truncate   tasble,代码如下:

public   Object   doInHibernate(Session   session)
              throws   HibernateException,   SQLException   {
          session.createSQLQuery( "truncate   table   customers ").executeUpdate();
                }

使用postgresql-7.3.1版本的数据库报错:
Exception   in   thread   "timerFactory "   org.springframework.jdbc.UncategorizedSQLException:   Hibernate   operation:   could   not   execute   native   bulk   manipulation   query;   uncategorized   SQLException   for   SQL   [truncate   table   tbl_easynet_alert_info];   SQL   state   [];   error   code   [0];   ERROR:     TRUNCATE   TABLE   cannot   run   inside   a   transaction   block;   nested   exception   is   org.postgresql.util.PSQLException:   ERROR:     TRUNCATE   TABLE   cannot   run   inside   a   transaction   block
Caused   by:   org.postgresql.util.PSQLException:   ERROR:     TRUNCATE   TABLE   cannot   run   inside   a   transaction   block

但是使用postgresql-8.3版本的数据,可以正常运行不会报错,这是什么原因,有没有什么解决办法啊,求助求助!!!

------解决方案--------------------
估计是1个限制,在7.3.1中事务块内不能运行TRUNCATE TABLE ,只有升级
------解决方案--------------------
改成delete from customers