Announcement Announcement Module
Collapse
No announcement yet.
Force flush with HibernateTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Force flush with HibernateTemplate

    Hi all,

    I hav ea small question, I use Spring with Hibernate and for simple methods like load, save, update or delete I use HibernateTemplate but if I check the database the commit is not done until the session is closed so I want to know how I can force the flush to save my modifications into the database?
    Thanks in advance.

    Kind regards.

  • #2
    HibernateTemplate has a method flush() that calls Session.flush().
    However, if you configured transactions for your data access method, the data will only be persisted / visible / in the database when the transaction is commited.

    Comment


    • #3
      ok thanks a lot sorry for these silly question

      Comment


      • #4
        I have always the same problem even I use the flush method of Hibernate Template.
        I haven't configured the the Transaction Manager Lookup.
        I ll try to find more information about transactions but if someone could help me it ll be cool
        thanks in advance

        Comment


        • #5
          If you are in the same transaction, then even without the maual flush the data will be visible to other Hibernate code (since it will look in its own cache, or flush itself as needed, such as it does before queires. W'regards to the data being visible to other JDBC code in the same transaction, you would need to do a manual flush, as the data would otherwise potentially still be in Hibernate's Session only. As for the data being visible outside of the transaction, before you have committed the transaction, you can't see it (depending on the isolation level of the datasource). The whole point of transactions is to shield one from another...

          Comment

          Working...
          X