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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:33:26+00:00 2026-06-13T17:33:26+00:00

In the below code: SessionFactory sessionFactory = new Configuration().configure(student.cfg.xml).buildSessionFactory(); Session session = sessionFactory.openSession(); //Transaction

  • 0

In the below code:

SessionFactory sessionFactory = new Configuration().configure("student.cfg.xml").buildSessionFactory();
    Session session = sessionFactory.openSession();
    //Transaction tran = session.beginTransaction();
    session.save(student);
    //tran.commit();
    session.flush();
    session.close();

Irrespective of whether I comment/uncomment the Transaction, they works fine i.e. without transaction also save operation is performed successfully. But whn I check the documentation then they always use the transaction before insert update delete. Any specific reasons for the same? Am I missing something?

Please let me know about this. I am fairly confused 🙁

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-13T17:33:27+00:00Added an answer on June 13, 2026 at 5:33 pm

    When you always use auto-commit, it may harm your db. Let’s say you want to commit bunch of work at a time. In this situation, you need to create transaction and commit all of your work after finishing all the job. For example, you need to do lots of database access for an atomic work for you. In that case, you need to do all the work in your transaction and commit all the work.

    Session session = factory.openSession();
    Transaction tx = session.beginTransaction();
    
    // do some work
    tx.commit();
    

    Of course with your catch blocks.

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

Sidebar

Related Questions

Below code : URL oracle = new URL(http://www.oracle.com/); URLConnection inputStream =oracle.openConnection(); InputStream in =
The below code doesn't it print the value. function go(x) { alert(x.options.selectedIndex.value); //location=document.menu.student.options[document.menu.student.selectedIndex].value }
HI: Below code is from RequestFactoryEditorDriver: /** * Returns a new array containing the
I have the following code that works fine in my spring.xml... <beans:bean id=sessionFactory class=org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean>
My code as below use Net::SSH::Expect; my $ssh = Net::SSH::Expect->new ( host => $node_name,
I have a Tomcat webapp that uses Hibernation Configuration, the code below silently fails
My code is as fallows below. My issue is the Session is not injected
I am using configuration as in the code listed below. auto create/drop function seams
Below code not work, but it's work fine for jsf1.2. Now the framework is
Below code saying error incorreect syntax near Main INSERT INTO tbl ( 'Week', Main,

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.