Hi,
What is the best approach to deleting a bunch of rows from a table by primary key?
currently i have this going on, but is there some shortcuts?
Code:
for (NodeElement node : deleteCandidates){
Query query = this.entityMgr.createNativeQuery("delete from node where id = :id");
query.setParameter("id", node.getId());
query.executeUpdate();
if (++i % FLUSH_SIZE == 0){
entityMgr.flush();
entityMgr.clear();
}
}
is building a giant "WHERE id IN ( " + node.getId() ", )" ... any better? I may need to delete hundreds or thousands or rows, but not ready for a stored procedure.