Difference between commit and flush in Hibernate

Discussion in 'Java' started by santax, May 28, 2007.

  1. santax

    santax Guest

    Hi
    Could you please tell me the difference between commit(method of
    Session) and flush(method of Transaction) in Hibernate?
    I read the book "Java Persistence with hibernate" which reference
    to DAO Pattern for JDK1.5.
    The main interface of the pattern is GenericDAO as below:

    public interface GenericDAO<T, ID extends Serializable> {
    T findById(ID id, boolean lock);
    List<T> findAll();
    List<T> findByExample(T exampleInstance,
    String... excludeProperty);
    T makePersistent(T entity);
    void makeTransient(T entity);
    void flush();
    void clear();
    }

    what me me puzzled is why it has no method commit? And when should I
    call the method flush and when shuold I commit the transaction if I
    use this pattern?
    Thanks.
     
    santax, May 28, 2007
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.