When you declare your Bean from type org.springframework.orm.hibernate3.LocalSessionFactoryBean you can initilize the property "eventListeners". This attribute is from type Map. The key defines the type of the event listeners (e.g. flush, load, delete, etc.). The value defines the corresponding class which implements the EventListener interface or extend the DefaultEventListener implementation class.
Sample of your context.xml
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
...
<property name="eventListeners">
<map>
<entry key="flush">
<bean class="org.j4fry.hibernate.eventlisteners.FlushEventListener" />
</entry>
</map>
</property>
...
</bean>
Sample of a FlushEventListener
package org.j4fry.hibernate.eventlisteners;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.event.FlushEvent;
import org.hibernate.event.def.DefaultFlushEventListener;
public class FlushEventListener extends DefaultFlushEventListener {
public void onFlush(FlushEvent fe) throws HibernateException {
super.onFlush(fe);
}
}
List of keys and the corresponding Interfaces and implementation-classesMap-Key | Interface | Default implementation class |
---|---|---|
auto-flush | AutoFlushEventListener | |
delete | DeleteEventListener | |
dirty-check | DirtyCheckEventListener | |
evict | EvictEventListener | |
flush-entity | FlushEntityEventListener | |
flush | FlushEventListener | |
load-collection | InitializeCollectionEventListener | |
load | LoadEventListener | |
lock | LockEventListener | |
merge | MergeEventListener | |
create-onflush | PersistEventListener | |
post-delete | PostDeleteEventListener | |
post-insert | PostInsertEventListener | |
post-load | PostLoadEventListener | |
post-update | PostUpdateEventListener | |
pre-delete | PreDeleteEventListener | |
pre-insert | PreInsertEventListener | |
pre-load | PreLoadEventListener | |
pre-update | PreUpdateEventListener | |
refresh | RefreshEventListener | |
replicate | ReplicateEventListener | |
save-update | SaveOrUpdateEventListener |
No comments:
Post a Comment