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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:14:49+00:00 2026-05-25T17:14:49+00:00

I have a scenario service layer is transactional, where i can only commit after

  • 0

I have a scenario service layer is transactional, where i can only commit after done trandaction. i simplified it into like below.

begin transaction

for(loop){

getHibernateTemplate().save(object);


getHibernateTemplate().get(object_by_key); //cannot get object by object_by_key because "object" is not commit into database until entire for(loop) completed. 

}

end transaction. commit();

i try to put getHibernateTemplate().flush(), after save() and able to see “insert” in show_sql. but the record is not showing inside database. how to force write to database after each save() rather than wait for commit like above ?

  • 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-25T17:14:49+00:00Added an answer on May 25, 2026 at 5:14 pm

    getHibernateTemplate().flush() is the method to force hibernate to write to the database (send insert & update queries). This is done within a transaction so it is not visible to other transactions (querying from a SQL client) till the transaction is committed.

    If the insert query is showing up in the log then it has been sent to the database. If you want to test that the record was inserted correctly – you can either do a getHibernateTemplate().clear() (which will remove all the cached data) and then do a getHibernateTemplate.get() (which will query from the dataSource). Or the other approach to test is to use the jdbcTemplate (with the same database) to query and check.

    If the SQL client tool you are using allows you to specify the Isolation level – starting the SQL client session in isolation read_uncommited – would allow you to see the changes done even before the transaction is commited.

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

Sidebar

Related Questions

I have a WCF svc separated into a Service Layer, Business Logic Layer and
Scenario I have a windows service written in C# that performs some processing based
Pretty simple scenario. I have a web service that receives a byte array that
Here is the scenario, I have a WCF service call that takes one string
Scenario I have two WCF Services combined in a single App.Config file. I can't
We have a design like below and I would like to get opinions or
Let's say I have a scenario where I have a Service that is responsible
Scenario: I'm currently writing a layer to abstract 3 similar webservices into one useable
I am looking into TDD and I have come across a scenario that I
I have a certain scenario where inserts and updates are done on multiple tables

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.