![]() You can replace any given default event listener with your own implementation. Or, the Interceptor#onLoad() is called by the DefaultPreLoadEventListener. For example, the Interceptor#onSave() method is invoked by Hibernate AbstractSaveEventListener. You provide a custom Interceptor, which is taken into consideration by the default Hibernate event listeners. When you want to customize the entity state transition behavior, you have two options: ![]() LOAD, new SecuredLoadEntityListener () ) SessionFactoryImplementor sessionFactory = entityManagerFactory.EntityManagerFactory entityManagerFactory = entityManagerFactory ().Here is an example of a custom load event listener: They are shared between requests, and should not save any state as instance variables.Ī custom listener implements the appropriate interface for the event it wants to process and/or extend one of the convenience base classes (or even the default event listeners used by Hibernate out-of-the-box as these are declared non-final for this purpose). The listeners should be considered stateless. ![]() When a request is made of one of these methods, the Session generates an appropriate event and passes it to the configured event listener(s) for that type.Īpplications can customize the listener interfaces (i.e., the LoadEvent is processed by the registered implementation of the LoadEventListener interface), in which case their implementations would be responsible for processing the load() requests made of the Session. The full range of defined event types is declared as enum values on .EventType. Many methods of the Session interface correlate to an event type. The event system can be used in place of or in addition to interceptors. If you have to react to particular events in the persistence layer, you can also use the Hibernate event architecture. applyInterceptor ( new LoggingInterceptor () )
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |