Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7572649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:58:41+00:00 2026-05-30T15:58:41+00:00

Consider the below two methods to delete a Set of Employees with the name

  • 0

Consider the below two methods to delete a Set of Employees with the name “John” .

List<Employee> list = new ArrayList<Employee>();
String query=   " from Employee emp where emp.name = 'John'";
list=getHibernateTemplate().find(query);

First Method:

 getHibernateTemplate().deleteAll(list);

Second Method:

Iterator<BulkChangeRequest> itList = list.iterator();
    while(itList.hasNext()) {
        Employee emp = itList.next();
        getHibernateTemplate().delete(emp);
    }

Do they differ significantly in terms of performance? Are both of them essentially the same i.e. does the deleteAll method delete row one by one?

Also wouldn’t it be better to do it in SQL using the following query?

" delete from Employee where name = 'John'"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:58:42+00:00Added an answer on May 30, 2026 at 3:58 pm

    Yes. It would be better to use SQL or HQL to delete all employee records named ‘John’ rather then the first option. Simply because in first option, you have to load all employee record from db to delete. That’s obviously an extra task.

    I think, for delete() and deleteAll(), there will be no difference except in delete(), it will create new session for every call; whereas in deleteAll(), all objects will be deleted in one session. But the number of queries will be the same.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider we have two tables ProductType and ProductSizeGroup as below ProductType Id Name MaleSizeGroupId
Consider the script below. It will launch two subprocesses, each one a CherryPy app
Consider the code below, private void Convert_Click(Object sender, RoutedEventArgs e) { string[] strCmdLineParams =
Consider I have two Horizontal ListView as shown below: list1 list2 I want to
Consider a situation we have two variables in SQL Server 2005's SP as below,
consider the below script. two arrays with only three values.when i compare these two
Consider the two implementations below, data.addRows([ ['2004', 1000], ['2005', 1170], ['2006', 660], ['2007', 1030]
Consider two tables as mentioned below - Table1 (id_col, name_col) Table2 (uid_col, code_col_1, code_col_2)
Consider the below: public class DependencyA {} public class DependencyB {} public class DependencyC
Consider the below situation I have a database table as below user_id user_rank ------------------

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.