256 APPENDIX A n MORE ADVANCED FEATURES APPENDIX (Web site construction)

256 APPENDIX A n MORE ADVANCED FEATURES APPENDIX A n MORE ADVANCED FEATURES Financial packages often require considerable auditing information to be maintained to prevent fraud and aid accountability. Auditing is a natural candidate for implementation as an interceptor, as it would normally require that no changes be made to the persistence process at all. The question that usually arises when discussing interceptors is why not use triggers? Triggers should never embody application logic, only business logic. If any application is going to have audit-free access to the database, you cannot implement the auditing in trig gers. Worse, the triggers may not have access to the user information that s needed. In most multi-tier situations, the need to pool the database connections precludes establishing indi vidual user logins to the database. So, for example, the trigger would only know that a user with the login MonolithicApplication carried out an update of last year s sales figures not that it was carried out by, say, Jim from accounts, which is who the auditors are likely to be interested in! Table A-2 summarizes the points in the application life cycle at which the vari ous methods will be invoked. Table A-2. The Interceptor Methods Name When Invoked Comments afterTransactionBegin() Invoked immediately after a call to begin() on a Transaction object retrieved from the Sessionobject. This method can change the state of the transaction for example, it can call rollback(). afterTransactionCompletion() Invoked immediately after the completion of a transaction. beforeTransactionCompletion() Invoked immediately prior to the completion of a transaction. This method can change the state of the transaction for example, it can call rollback(). findDirty() Invoked during calls to flush(). This allows the saving of changes to attributes to be prevented or forced. getEntity() Invoked when an entity not in the Session object s own cache is requested by its identifier. getEntityName() Invoked when the Session object needs to determine the name of a given entity. instantiate() Invoked when the Session object needs to create an entity instance. Because the empty object can be created here, this allows Hibernate (in legacy applications, for example) to use entities that do not have a default constructor. isTransient() Invoked when the Session object needs to determine whether an entity it has been asked to persist is transient for example, during calls to saveOrUpdate(). onDelete() Invoked before an object is deleted. The object s state should not be tampered with at this point.
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

Leave a Reply