复杂的Activiti + JPA查询 [英] Complex Activiti + JPA queries

查看:244
本文介绍了复杂的Activiti + JPA查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试在新项目中使用Activiti.我创建了一个设置,该设置使用Hibernate通过JPA持久化流程中涉及的实体,并且JPA与Activiti互连,因此我们可以将这些实体用作JPA变量.请参阅: Activiti文档的JPA章节

We are trying to use Activiti in a new project. I've created a setup which uses Hibernate through JPA for persisting entities involved in the process and JPA is interconnected with Activiti so we can use these entities as JPA variables. See: JPA chapter of Activiti's documentation

我发现Activiti不允许我对涉及JPA变量的流程创建查询,而我希望在这些流程中对JPA实体字段进行过滤.例如,如果我的流程具有引用Book实体的变量,则无法为包含特定标题的书的流程创建查询.

I've found out that Activiti doesn't allow me to create queries on processes which involves JPA variables where i like to filter on the JPA entity fields. For example if i have processes with a variable referencing Book entities i can't create a query for processes which have a book with a specific title.

克服此问题的最佳方法是什么?我虽然要用Hibernate分别查询实体,然后在Activiti上进行第二次查询,以获取所涉及的进程,但是我深信这会很慢.另外,如果我正在做相反的事情(首先查询进程,然后对实体使用Hibernate进行第二次查询),Activiti会不必要地填充JPA变量,而我无法找出仅获取实体ID的方法.保存到我数据库的Activiti变量表中.

What's the best method to overcome this? I though about querying the entities seperately with Hibernate then do a second query on Activiti to get the processes involved however i'm affraid it will be slow. Also if i'm doing it the other way around (querying the processes first then do a second query with Hibernate on the entities) Activiti does an unnecessarry fill of the JPA variables and i couldn't find out how to get only the entity ID which saved into the Activiti variables table of my database.

推荐答案

我已经实现了问题注释中描述的解决方案.我还没有一个大数据集来测试性能,但似乎可以接受.

I've implemented my solution descirbed in the questions comments. I don't yet have a big dataset to test performance but it seems acceptable.

这篇关于复杂的Activiti + JPA查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆