APPENDIX A n (Web hosting uk) MORE ADVANCED FEATURES 257 n

APPENDIX A n MORE ADVANCED FEATURES 257 n MORE ADVANCED FEATURES 257 Name When Invoked Comments onFlushDirty() Invoked during a call to flush() after entities have been determined to be dirty. (If the entities are not dirty, then there are no changes to be persisted and Hibernate has no actions to perform therefore, there is no general case interceptor, and this interceptor will not be invoked if the entities are clean.) onLoad() Invoked immediately before an entity object is populated from the database. The loading can be overridden (by returning false), and the instantiated but uninitialized object is available if supplementary initialization from the listener is needed. onSave() Invoked before an object is saved. This permits the state of the object to be changed immediately before it is saved. postFlush() Invoked after the Session object is flushed, if and only if the Session object had to carry out SQL operations to synchronize state with the database. preFlush() Invoked immediately before the Session object is flushed. An Example Interceptor To illustrate how all this works in practice, we will create a simple interceptor from scratch. While the auditing example is a good one, it is rather too involved for our demonstration. Instead, we will consider a concert hall seat-booking system (the entity to represent an entity is shown in Listing A-24) for which the details of bookings will be sent out to customers as they are pushed into the database. Listing A-24. The Booking POJO package com.hibernatebook.advanced.events; public class Booking { public Booking(String name, String seat) { this.name = name; this.seat = seat; } Booking() { }
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Leave a Reply