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 8780963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:11:03+00:00 2026-06-13T20:11:03+00:00

I want to perform a hibernate batch insert using HibernateTemplate but I am not

  • 0

I want to perform a hibernate batch insert using HibernateTemplate but I am not able to find the correct jar containing this class. I know that it should present in spring.jar but not able to find out where to download the spring.jar. For getting this jar, I tried with downloading the entire spring framework also but unfortunately did not found anything like spring.jar in the downloaded package. May be the name is changed, can you please let me know in which jar can I find this HibernateTemplate class??

Also, shall we use the HibernateTemplate class for batch insert in hibernate or there are some other better alternative for batch insert in hibernate?

Regards,

  • 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-06-13T20:11:04+00:00Added an answer on June 13, 2026 at 8:11 pm

    It is not recommended to use Hibernate for batch processing. Unless you already have a business layer built with Hibernate, and you want to reuse some code, you should do your batch processing in plain old JDBC, perhaps managed by a framework like Spring Batch.

    If you want to use Hibernate, then you should use a StatelessSession.

    There’s no need for any HibernateTemplate since the Session already provides you everything you need.


    Edit:
    you can handle transactions:

    Session session = sessionFactory.openStatelessSession();
    Transaction tx = session.beginTransaction();
    // DO SOMETHING
    tx.commit();
    session.close();
    

    By the way if you create a transaction for 10 items then I guess you want to split your treatment into multiple transactions of 10 insertions. Is transaction really needed? Because anyway one transaction can fail while the others do not, and that leaves you with some inserted entities, and some that are not.

    If you want atomicity of your batch treatment (all inserted, or none inserted) you must run the transaction for all the elements, and not only 10 of them. But take care to not lock your database… I don’t think it’s a good idea to use a big long running transaction for a batch. Instead you probably should compensate the insertion failures on your own.

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

Sidebar

Related Questions

I want to perform a native/raw mysql query using hibernate, I have this: sessionFactory.getCurrentSession().createSQLQuery(
I am using hibernate as ORM tool, i want to perform some common stuff
I want to perform changes in the code which was developed using iOS 3.0,
I want do a one-to-many relationship between two tables using a join table. This
Suppose I want perform a simulation using the following function : fn1 <- function(N)
I want to perform a case insensitive sub-string first appearance replacement. I've tried this
I've been using Hibernate for years and never have a problem with it, but
I want to perform this.Controls.Add(MyObject) in the class definition of MyObject like public MyClass(container/*?*/
I want to perform not operation to a block of continous elements of a
I want to perform GridSearchCV in a SVC model, but that uses the one-vs-all

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.