I've got a JPA entity that is loaded via dynamic ejb ql queries that can be configured by the user fairly freely. In comes a new requirement: Users should be allowed to create new entities only iff these new entites would be returned by their user specific queries. So, I think I'd need to instanciate a JPA-Entity, create an EJB-Query dynamically and figure out if the entity would be loaded by this query if it existed in the database.
How could I do that? Is there, for example, a standalone JPA cache so that I could push the new JPA entity into the cache and question it with my query, without ever hitting the database?