Search code examples
jpqlcorda

Custom JPQL query in Corda for doing group by operations


I have a queryable state in which I have a sender and amount fields. Is it possible to write a custom HQL or JPQL queries to get the total sum grouped by each sender. example

select sender,sum(amount) from stateTable group by sender

If possible please let me know how


Solution

  • I used the JDBC session present in the serviceHub to add the custom JDBC query. Please find below the reference for the same

    https://docs.corda.net/api-persistence.html#jdbc-session-ref