简体   繁体   English

Complex Activiti + JPA查询

[英]Complex Activiti + JPA queries

We are trying to use Activiti in a new project. 我们正在尝试在新项目中使用Activiti。 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. 我已经创建了一个使用Hibernate通过JPA的设置,用于持久化参与该过程的实体,JPA与Activiti互连,因此我们可以将这些实体用作JPA变量。 See: JPA chapter of Activiti's documentation 请参阅: Activiti文档的JPA章节

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. 我发现Activiti不允许我在涉及JPA变量的进程上创建查询,我想在JPA实体字段上进行过滤。 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. 例如,如果我的进程具有引用Book实体的变量,则无法为具有特定标题的书籍的进程创建查询。

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. 我虽然单独使用Hibernate查询实体,然后在Activiti上进行第二次查询以获得所涉及的过程但是我担心它会很慢。 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. 另外,如果我正在反过来(首先查询进程然后在实体上使用Hibernate进行第二次查询)Activiti做了不必要的JPA变量填充,我无法找到如何只获取实体ID保存到我的数据库的Activiti变量表中。

what about using your entity's ID as businessKey of your process? 将您实体的ID用作流程的businessKey怎么样?

You could then do a query on your entities (Books with specific titles) and then use that to retrieve you processes in Activiti 然后,您可以对您的实体(具有特定标题的书籍)进行查询,然后使用它来检索Activiti中的流程

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. 我还没有一个大的数据集来测试性能,但似乎可以接受。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM