在hibernate 2時.一些批量的sql 操作,經常產生性能影響如刪除100000個.在內存中加載如此多的對像是沒有必要,所以我們的解決方法就是在hibernate中直接用JDBC 操作
session.connection();
Statment st=connection.createSatement().....等直接JDBC操作解決性能問題.
現在hibnate中可能直接用HQL 進行批量操作,性能和用JDBC操作一樣,
如String hql="delete news"
String hql="update news n where n.newsId<10000";
Query query=session.createQuery(hql);
int size=query.executeUpdate()就行了..