怎么在hibernate下使用truncate table
Java code
public void deleteAll() {
session = super.getSession();
ts = session.beginTransaction();
String sql ="truncate table Count";
Query query=session.createQuery(sql);
query.executeUpdate();
ts.commit();
session.close();
}
我想truncate一张表,可是报错
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: truncate near line 1, column 1 [truncate table Count]
是不是hql不支持truncate
------解决方案--------------------
createSQLQuery
------解决方案--------------------
createQuery
->>>
createSQLQuery