我使用PostgreSQL数据库,想要使用JPA EntityManager来启动VACUUM FULL。
public void doVacuum(){
entityManager.createNativeQuery("VACUUM FULL").executeUpdate()
}
抛出TransactionRequiredException异常。
版本2
@Transactional
public void doVacuum(){
entityManager.createNativeQuery("VACUUM FULL").executeUpdate()
}
抛出PersistenceException异常 "VACUUM不能在事务块内运行"
版本3
public void doVacuum(){
entityManager.createNativeQuery("VACUUM FULL").getResultList()
}
执行了清空操作后,但之后出现了PersistenceException "没有结果"。
正确的启动这个SQL命令的方式是什么?