Reputation: 1033
one major doubt regarding delete option in DAO layer! which approach is better for mass delete when there is multiple where conditions are there, and why ?:-
1 approach
EntityManager.remove();
2 approach
EntityManager.createNamedQuery(DeleteQuery);
thanks
Upvotes: 0
Views: 31
Reputation: 118701
The NamedQuery, by far.
You can delete several rows with a single query -- that's a big win right there.
Even if you had to delete thing individually, with the EntityManager, you need to have the actual entity to delete. Whereas with a NamedQuery, you only need the key -- no reason to read the entity in the first place.
Much, much faster overall.
Upvotes: 3