Camunda Team Blog

How to

Custom Queries

Written by Yana Vasileva on , under Execution category.
Why Custom Queries? The process engine offers a pretty straightforward and easy to use Java Query API. If you want to build a task list you just write something like this: @Inject private TaskService taskService; public List<Task> getAllTasks() { return taskService.createTaskQuery().taskAssignee("bernd").list(); } Easy as it is, there are basically two catches: You can only build queries that the API supports. You cannot add constraints on your domain objects. Let us give you a simple use case example, which we implemented in the custom-queries example: You have a process variable “customer” holding the customerId You have your own entity “Customer” with all the details Custom Query Domain Example So far, a pretty common situation (please note that the object diagram has been simplified to show the relevant aspects and doesn’t precisely correspond to the implementation classes).