cancel
Showing results for 
Search instead for 
Did you mean: 

Query process instances and JPA entity

ollib
Champ in-the-making
Champ in-the-making
I have a process with a JPA entity "vacation". When I created the process instance, I also create an empty vacation record in the database. The vacation record also stores the associated process instance id.

I also have a process instance search where i can do things like:

List<HistoricProcessInstance> processInstances =
  historyService.createNativeHistoricProcessInstanceQuery()
                .sql("SELECT * FROM " + managementService.getTableName(HistoricProcessInstance.class) +
                     " h, vacations v where h.proc_inst_id_ = v.processinstanceid and v.decision = 'Denied'")
                .list();


As I understand the createNativeHistoricProcessInstanceQuery method, it works with pure SQL.

Would it be possible to make such queries with JPA or Hibernate? I use HibernatePersistence for my vacation objects.

Best regards
Oliver Brüning
1 REPLY 1

trademak
Star Contributor
Star Contributor
You can access the EntityManagerSession object that provides an EntityManager. So you can use the EntityManager instance to execute any queries you would like to execute. You can get it from the ProcessEngineConfiguration getSessionfactories method.

Best regards,