APPENDIX A n MORE ADVANCED FEATURES 253 n (Cpanel web hosting)

APPENDIX A n MORE ADVANCED FEATURES 253 n MORE ADVANCED FEATURES 253 Type Name Listener pre-delete PreDeleteEventListener pre-insert PreInsertEventListener pre-load PreLoadEventListener pre-update PreUpdateEventListener refresh RefreshEventListener replicate ReplicateEventListener save-update SaveOrUpdateEventListener So, for example, your listener for the SaveOrUpdateEvent is mapped to the type name save-update, must implement the SaveOrUpdateEventListener interface, and would normally have been implemented by the DefaultSaveOrUpdateEventListener class. It is wise to follow a similar convention with your own naming, so your mapping file listener entry might read like this:
Alternatively, a programmatic registration of the same event would be given thus: Configuration config = new Configuration(); config.setListener(”save-update”, new BookingSaveOrUpdateEventListener()); Because they override the default behavior, events are suitable for situations in which you want to fundamentally change the Session s behavior particularly if you want to prevent a certain event from being processed. Probably the best example of this requirement is in authorizing access to the database, and, in fact, Hibernate provides a set of event listeners for just this purpose. The four events listeners in question override the PreDelete, PreUpdate, PreInsert, and PreLoad listeners. The logic in each case (in pseudocode) runs something like this: if( user does not have permission ) throw RuntimeException Invoke default listener Because events are invoked in the same thread as the user s call to the session, the result of an exception in the first step will be an exception (actually a security exception) as the unprivileged user carries out the relevant operation. To enable policy configuration of security, you would add the following:
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

Leave a Reply