I have five filter fields in my application home page (dashboard → where I am showing all the records from h2 DB) now I want to filter the records on these fields basis.
It may require 31 (2^5 -1) queries, some are already provided as default queries.
Isn’t there a way to write a dynamic query in “custom queries” or somewhere to get the desired result at UI?
Things I have tried:
get all the records and apply javascript filters (not a good approach)
e.g. In query “findByFirstName” when retrieving records on the basis of firstName, I also pass " ‘firstNameHere’ AND = ‘something’ "
this doesn’t work.
That’s easy…
But I want some dynamic query i.e. at runtime to build the query on the basis of some fields.
e.g. append AND clause with some other attribute.
For a semi-dynamic query, parameters could be helpful.
But there is nothing to execute JPQL using default APIs. What you could do is to create a Bonita Command ( javadoc ) to extend the default Java API of Bonita and come with an implementation that would leverage the Business Data Service . Here is a Bonita architecture overview in case you want to learn a bit more about this.
Bonitasoft empowers development teams with Bonita, the open-source and extensible platform to solve the most demanding process automation use cases. The Bonita platform accelerates delivery of complex applications with clear separation between capabilities for visual programming and for coding. Bonita integrates with existing solutions, orchestrates heterogeneous systems, and provides deep visibility into processes across the organization.