Results 1 to 5 of 5

Thread: Force flush with HibernateTemplate

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Posts
    10

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    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.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Aug 2004
    Posts
    10

    Default

    ok thanks a lot sorry for these silly question

  4. #4
    Join Date
    Aug 2004
    Posts
    10

    Default

    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

  5. #5
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    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...
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

Similar Threads

  1. HibernateTemplate and transactions
    By Simon Brunning in forum Data
    Replies: 4
    Last Post: Mar 9th, 2009, 12:37 AM
  2. Replies: 5
    Last Post: Dec 7th, 2006, 05:53 AM
  3. Context initialization failed
    By kanonmicke in forum Container
    Replies: 7
    Last Post: Sep 29th, 2005, 12:35 AM
  4. Inject HibernateTemplate into DAO
    By foamdino in forum Data
    Replies: 5
    Last Post: Jul 6th, 2005, 06:56 AM
  5. Replies: 4
    Last Post: May 4th, 2005, 01:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •