Hibernate as ORM, there is an inherent problem, that is, because in order to last for persistence objects, it is not possible to use bulk deletion and batch update SQL, can only be operated in accordance with primary key. Therefore, the efficiency is relatively low relative to JDBC. However, things are not always so desperate, as long as you optimize Hibernate, you can also get quite satisfactory speed. Session.delete ("from cat as c where ...");
This statement actually sends SQL: ==> SELECT ID, NAME, SEX, Weight from Cat;
==> DELETE from cat where =?
Hibernate first querying the data, does consume some time, but SELECT read-only operations and INSERT, DELETE, UPDATE These database modifications have more than one order level gap on the speed. Therefore, although Hibernate is more consumed, it is not a lot of impact, mainly in memory consumption. DELETE's speed, we know that Hibernate's Batch Size can provide greatly improve INSERT, DELETE, and UPDATE. My test: Oracle817, ojdbc14.jar table record 10,000, all deleted. JDBC: SQL statement delete from cat
Speed: Average 6S Hibernate: Session.delete ("from cat as c");
Batch size = 0 speed: 25s Batch size = 50 Speed: 6S Batch Delete and Batch Update Recommended JDBC, this is a principle, of course, sometimes you may have to use Hibernate to batch update and batch deletion, then I want to say at this time. That is, hibernate is quantified and deleted efficiency is not the legendary, as long as the optimization is good, the speed is very fast.