I'll explain how to use hibernate to create and drop index statements for a domain class and add how to implement this logic as two new methods on the domain class.
che that is available is the query cache. The query cache effectively holds on to the identifiers for an individual query. As described in the documentation: