What is the best way to delete all rows in a table in Hibernate?
If I iterate over a collection and call session.delete()
it's not performing to my knowledge.
If I use another option session.createQuery("delete ...")
it doesn't affect persistence context.
When I should use these methods if there is no better variant?
You can use HQL for truncate table
public int hqlTruncate(String myTable){
String hql = String.format("delete from %s",myTable);
Query query = session.createQuery(hql)
return query.executeUpdate();
}