Summary

In this chapter, we discussed Java's SPI and OSGi model. This was necessary in order to understand the event architecture. As we saw, event listeners can be registered as services to respond to certain actions that take place in the persistence context. This sophisticated architecture empowers Hibernate to be pluggable and enables runtime environments to act as service providers.

We also discussed interceptors, which offer capability similar to events, but they are easier to create and use. The simplicity of interceptors is due to their lacking the sophisticated architecture that is used by events. For this reason, they are less modular and pluggable.

Finally, we looked at envers, which enable entity versioning and audit mechanisms. We showed ...

Get Mastering Hibernate now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.