Listening in Hibernate
The event monitoring mechanism in hibernate can listen to the action of the session object, and hibernate invokes the event-handling method in the listener class once a special event occurs. In some features of the design, can either use Hibernate interceptor implementation, or can use Hibernate's event monitoring to achieve.
Hibernate can also be used to monitor, perform before and after the save operation.
The first step:
Write listeners to implement specific interfaces. Different interfaces are implemented for different operations.
Step Two: Configure the Listener
Concrete operation according to the actual implementation.
Best Practices for Hibernate
1, more use of fine-grained components, componment
2, the primary key is best meaningless
3, preferably each persistent class corresponds to a mapping file
4, consider putting the query string outside the program, that is, using a named query
5. Using Bound variables: =name
6, do not treat anomalies as recoverable, try to use runtimeexception instead of exception
7. Consider abstracting hibernate code from business logic code
8, multi-use bidirectional association
Hibernate basic knowledge Finishing (vi)