KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > event > def > DefaultFlushEventListener


1 //$Id: DefaultFlushEventListener.java,v 1.4 2005/05/27 03:53:59 oneovthafew Exp $
2
package org.hibernate.event.def;
3
4 import org.hibernate.HibernateException;
5 import org.hibernate.event.EventSource;
6 import org.hibernate.event.FlushEvent;
7 import org.hibernate.event.FlushEventListener;
8
9 /**
10  * Defines the default flush event listeners used by hibernate for
11  * flushing session state in response to generated flush events.
12  *
13  * @author Steve Ebersole
14  */

15 public class DefaultFlushEventListener extends AbstractFlushingEventListener implements FlushEventListener {
16
17     /** Handle the given flush event.
18      *
19      * @param event The flush event to be handled.
20      * @throws HibernateException
21      */

22     public void onFlush(FlushEvent event) throws HibernateException {
23         final EventSource source = event.getSession();
24         if ( source.getPersistenceContext().hasNonReadOnlyEntities() ) {
25             
26             flushEverythingToExecutions(event);
27             performExecutions(source);
28             postFlush(source);
29         
30             if ( source.getFactory().getStatistics().isStatisticsEnabled() ) {
31                 source.getFactory().getStatisticsImplementor().flush();
32             }
33             
34         }
35     }
36 }
37
Popular Tags