Normally during a native query the entire second-level cache is cleared unless it is explicitly stated which entities the query affects. In our situation we want to execute the following PostgreSQL command which clearly doesn't affect any entity. If the second-level cache is always cleared this can potentially cause a major performance issue.
BulkOperationCleanupAction coordinates the cache cleanup. It uses the method affectedEntity() to check if a given entity is on the list of explicitly stated affected entities. If the list of affected entities is empty the entire cache is cleared, as can be seen here:
As a workaround I implemented following method which adds a dummy entry to the list of affected entities, effectively preventing the cache cleanup.