I have some trivial table in database (let say Oracle10g) and I need to implement at DAO ability to delete multiple records. The method remove()
receives as a parameter an array of ids (integers).
For now I have a query string "DELETE FROM news WHERE id = ?"
which I use at PreparedStatement. I simply add batch for every id from array and then perform execute on PreparedStatement.
I wonder if there any ability to perform it through one query statement, something like "DELETE FROM news WHERE id IN ?"
. But I cannot find how to properly set an array of integers instead of '?'
.
The same question applies to Hibernate and JPA. If there any constructions to solve this ? Because now I use batch-like-way: add Query to Session on every id from array and commit transaction.