Difference between commit and flush in Hibernate

S

santax

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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top