开发者

How to load JPA entites via dynamic EJB-QL from standalone cache, without hitting the database

开发者 https://www.devze.com 2023-03-08 15:27 出处:网络
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 t

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?


You could just insert the new entity in database, perform the query, see if the entity is found, and rollback if not found (or delete the entity in the same transaction if you don't want to rollback).

0

精彩评论

暂无评论...
验证码 换一张
取 消