|
I think you should be able to intercept it, or somehow decorate the Session factory.
Even so, it might be interesting to propose a new configuration option to ORM to be able to configure 2LC but having it disabled by default, and an option to manually enable on a specific Session instance.
From an architecture point of view, it looks like your Search layer needs strong isolation from the rest of your code, which implies you have two other clean options available:
-
run the Hibernate Search using code using a different Hibernate instance (configured with caching)
-
use Infinispan Query: uses the same annotations from Hibernate Search but excplicitly caches everything in an in-memory grid, seems a good fit for your high-speed requirements
|