需要 import org.hibernate.Session;
EntityManager entityManager = entityManagerFactory.createEntityManager();
try{
EntityTransaction transaction = entityManager.getTransaction();
transaction.begin();
Session session = (Session) entityManager.getDelegate();
session.setFlushMode(FlushMode.MANUAL);
Query query = entityManager.createQuery("delete from PropertyView");
query.executeUpdate();
for (PropertyView pv :
propertyViewList) {
session.save(pv);
}
session.flush();
session.clear();
transaction.commit();
}catch (Exception e){
throw e;
}finally {
entityManager.close();
}