org.activiti.engine.impl.persistence.entity.VariableInstanceEntity Java Examples
The following examples show how to use
org.activiti.engine.impl.persistence.entity.VariableInstanceEntity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HistoricProcessInstanceVariableDataResource.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public RestVariable getVariableFromRequest(boolean includeBinary, String processInstanceId, String variableName, HttpServletRequest request) { HistoricProcessInstance processObject = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).includeProcessVariables().singleResult(); if (processObject == null) { throw new ActivitiObjectNotFoundException("Historic process instance '" + processInstanceId + "' couldn't be found.", HistoricProcessInstanceEntity.class); } Object value = processObject.getProcessVariables().get(variableName); if (value == null) { throw new ActivitiObjectNotFoundException("Historic process instance '" + processInstanceId + "' variable value for " + variableName + " couldn't be found.", VariableInstanceEntity.class); } else { return restResponseFactory.createRestVariable(variableName, value, null, processInstanceId, RestResponseFactory.VARIABLE_HISTORY_PROCESS, includeBinary); } }
Example #2
Source File: GetExecutionsVariablesCmd.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public List<VariableInstance> execute(CommandContext commandContext) { // Verify existence of executions if (executionIds == null) { throw new ActivitiIllegalArgumentException("executionIds is null"); } if (executionIds.isEmpty()){ throw new ActivitiIllegalArgumentException("Set of executionIds is empty"); } List<VariableInstance> instances = new ArrayList<VariableInstance>(); List<VariableInstanceEntity> entities = commandContext.getVariableInstanceEntityManager().findVariableInstancesByExecutionIds(executionIds); for (VariableInstanceEntity entity : entities){ entity.getValue(); instances.add(entity); } return instances; }
Example #3
Source File: GetTasksLocalVariablesCmd.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public List<VariableInstance> execute(CommandContext commandContext) { if (taskIds == null) { throw new ActivitiIllegalArgumentException("taskIds is null"); } if (taskIds.isEmpty()){ throw new ActivitiIllegalArgumentException("Set of taskIds is empty"); } List<VariableInstance> instances = new ArrayList<VariableInstance>(); List<VariableInstanceEntity> entities = commandContext.getVariableInstanceEntityManager().findVariableInstancesByTaskIds(taskIds); for (VariableInstanceEntity entity : entities){ entity.getValue(); instances.add(entity); } return instances; }
Example #4
Source File: GetExecutionsVariablesCmd.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public List<VariableInstance> execute(CommandContext commandContext) { // Verify existence of executions if (executionIds == null) { throw new ActivitiIllegalArgumentException("executionIds is null"); } if (executionIds.isEmpty()) { throw new ActivitiIllegalArgumentException("Set of executionIds is empty"); } List<VariableInstance> instances = new ArrayList<>(); List<VariableInstanceEntity> entities = commandContext.getVariableInstanceEntityManager().findVariableInstancesByExecutionIds(executionIds); for (VariableInstanceEntity entity : entities) { entity.getValue(); instances.add(entity); } return instances; }
Example #5
Source File: GetTasksLocalVariablesCmd.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public List<VariableInstance> execute(CommandContext commandContext) { if (taskIds == null) { throw new ActivitiIllegalArgumentException("taskIds is null"); } if (taskIds.isEmpty()) { throw new ActivitiIllegalArgumentException("Set of taskIds is empty"); } List<VariableInstance> instances = new ArrayList<>(); List<VariableInstanceEntity> entities = commandContext.getVariableInstanceEntityManager().findVariableInstancesByTaskIds(taskIds); for (VariableInstanceEntity entity : entities) { entity.getValue(); instances.add(entity); } return instances; }
Example #6
Source File: SerializableType.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void setValue(Object value, ValueFields valueFields) { byte[] byteArray = serialize(value, valueFields); valueFields.setCachedValue(value); if (valueFields.getBytes() == null) { // TODO why the null check? won't this cause issues when setValue is called the second this with a different object? if (valueFields instanceof VariableInstanceEntity) { // register the deserialized object for dirty checking. Context.getCommandContext() .getDbSqlSession() .addDeserializedObject(new DeserializedObject(this, valueFields.getCachedValue(), byteArray, (VariableInstanceEntity) valueFields)); } } super.setValue(byteArray, valueFields); }
Example #7
Source File: SerializableType.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public Object getValue(ValueFields valueFields) { Object cachedObject = valueFields.getCachedValue(); if (cachedObject != null) { return cachedObject; } byte[] bytes = (byte[]) super.getValue(valueFields); if (bytes != null) { Object deserializedObject = deserialize(bytes, valueFields); valueFields.setCachedValue(deserializedObject); if (valueFields instanceof VariableInstanceEntity) { // we need to register the deserialized object for dirty checking, // so that it can be serialized again if it was changed. Context.getCommandContext() .getDbSqlSession() .addDeserializedObject(new DeserializedObject(this, deserializedObject, bytes, (VariableInstanceEntity) valueFields)); } return deserializedObject; } return null; // byte array is null }
Example #8
Source File: TaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testNativeQuery() { assertEquals("ACT_RU_TASK", managementService.getTableName(Task.class)); assertEquals("ACT_RU_TASK", managementService.getTableName(TaskEntity.class)); assertEquals(12, taskService.createNativeTaskQuery().sql("SELECT * FROM " + managementService.getTableName(Task.class)).list().size()); assertEquals(12, taskService.createNativeTaskQuery().sql("SELECT count(*) FROM " + managementService.getTableName(Task.class)).count()); assertEquals(144, taskService.createNativeTaskQuery().sql("SELECT count(*) FROM ACT_RU_TASK T1, ACT_RU_TASK T2").count()); // join task and variable instances assertEquals(1, taskService.createNativeTaskQuery().sql("SELECT count(*) FROM " + managementService.getTableName(Task.class) + " T1, " + managementService.getTableName(VariableInstanceEntity.class)+" V1 WHERE V1.TASK_ID_ = T1.ID_").count()); List<Task> tasks = taskService.createNativeTaskQuery().sql("SELECT * FROM " + managementService.getTableName(Task.class) + " T1, " + managementService.getTableName(VariableInstanceEntity.class)+" V1 WHERE V1.TASK_ID_ = T1.ID_").list(); assertEquals(1, tasks.size()); assertEquals("gonzoTask", tasks.get(0).getName()); // select with distinct assertEquals(12, taskService.createNativeTaskQuery().sql("SELECT DISTINCT T1.* FROM ACT_RU_TASK T1").list().size()); assertEquals(1, taskService.createNativeTaskQuery().sql("SELECT count(*) FROM " + managementService.getTableName(Task.class) + " T WHERE T.NAME_ = 'gonzoTask'").count()); assertEquals(1, taskService.createNativeTaskQuery().sql("SELECT * FROM " + managementService.getTableName(Task.class) + " T WHERE T.NAME_ = 'gonzoTask'").list().size()); // use parameters assertEquals(1, taskService.createNativeTaskQuery().sql("SELECT count(*) FROM " + managementService.getTableName(Task.class) + " T WHERE T.NAME_ = #{taskName}").parameter("taskName", "gonzoTask").count()); }
Example #9
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void recordVariableUpdate(VariableInstanceEntity variable) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { HistoricVariableInstanceEntity historicProcessVariable = getDbSqlSession() .findInCache(HistoricVariableInstanceEntity.class, variable.getId()); if (historicProcessVariable == null) { historicProcessVariable = Context.getCommandContext() .getHistoricVariableInstanceEntityManager() .findHistoricVariableInstanceByVariableInstanceId(variable.getId()); } if (historicProcessVariable != null) { historicProcessVariable.copyValue(variable); } else { HistoricVariableInstanceEntity.copyAndInsert(variable); } } }
Example #10
Source File: MockVariableScope.java From lemon with Apache License 2.0 | 6 votes |
public MockVariableScope(Integer eventCode, String eventName, ModelInfoDTO modelInfo, String userId, String activityId, String activityName) { usedVariablesCache.put("eventCode", VariableInstanceEntity.create( "eventCode", new IntegerType(), eventCode)); usedVariablesCache.put("eventName", VariableInstanceEntity.create( "eventName", new StringType(64), eventName)); usedVariablesCache.put("modelInfo", VariableInstanceEntity.create( "modelInfo", new SerializableType(), modelInfo)); usedVariablesCache.put("userId", VariableInstanceEntity.create( "userId", new StringType(64), userId)); usedVariablesCache.put("activityId", VariableInstanceEntity.create( "activityId", new StringType(64), activityId)); usedVariablesCache.put("activityName", VariableInstanceEntity.create( "activityName", new StringType(64), activityName)); }
Example #11
Source File: SerializableType.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public Object getValue(ValueFields valueFields) { Object cachedObject = valueFields.getCachedValue(); if (cachedObject != null) { return cachedObject; } byte[] bytes = (byte[]) super.getValue(valueFields); if (bytes != null) { Object deserializedObject = deserialize(bytes, valueFields); valueFields.setCachedValue(deserializedObject); if (trackDeserializedObjects && valueFields instanceof VariableInstanceEntity) { Context.getCommandContext().addCloseListener(new VerifyDeserializedObjectCommandContextCloseListener( new DeserializedObject(this, valueFields.getCachedValue(), bytes, (VariableInstanceEntity)valueFields))); } return deserializedObject; } return null; // byte array is null }
Example #12
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void recordVariableRemoved(VariableInstanceEntity variable) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { HistoricVariableInstanceEntity historicProcessVariable = getDbSqlSession() .findInCache(HistoricVariableInstanceEntity.class, variable.getId()); if (historicProcessVariable == null) { historicProcessVariable = Context.getCommandContext() .getHistoricVariableInstanceEntityManager() .findHistoricVariableInstanceByVariableInstanceId(variable.getId()); } if (historicProcessVariable != null) { Context.getCommandContext() .getHistoricVariableInstanceEntityManager() .delete(historicProcessVariable); } } }
Example #13
Source File: DefaultHistoryManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void recordVariableCreate(VariableInstanceEntity variable) { // Historic variables if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { getHistoricVariableInstanceEntityManager().copyAndInsert(variable); } }
Example #14
Source File: MybatisVariableInstanceDataManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public List<VariableInstanceEntity> findVariableInstancesByExecutionAndNames(String executionId, Collection<String> names) { Map<String, Object> params = new HashMap<String, Object>(2); params.put("executionId", executionId); params.put("names", names); return getDbSqlSession().selectList("selectVariableInstancesByExecutionAndNames", params); }
Example #15
Source File: MybatisVariableInstanceDataManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public VariableInstanceEntity findVariableInstanceByTaskAndName(String taskId, String variableName) { Map<String, String> params = new HashMap<String, String>(2); params.put("taskId", taskId); params.put("name", variableName); return (VariableInstanceEntity) getDbSqlSession().selectOne("selectVariableInstanceByTaskAndName", params); }
Example #16
Source File: DbSqlSession.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void dispatchEventsForRemovedOperations(List<DeleteOperation> removedOperations) { for (DeleteOperation delete : removedOperations) { // dispatch removed delete events if (delete instanceof CheckedDeleteOperation) { CheckedDeleteOperation checkedDeleteOperation = (CheckedDeleteOperation) delete; PersistentObject persistentObject = checkedDeleteOperation.getPersistentObject(); if (persistentObject instanceof VariableInstanceEntity) { VariableInstanceEntity variableInstance = (VariableInstanceEntity) persistentObject; Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( createVariableDeleteEvent(variableInstance)); } } } }
Example #17
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void recordHistoricDetailVariableCreate(VariableInstanceEntity variable, ExecutionEntity sourceActivityExecution, boolean useActivityId) { if (isHistoryLevelAtLeast(HistoryLevel.FULL)) { HistoricDetailVariableInstanceUpdateEntity historicVariableUpdate = HistoricDetailVariableInstanceUpdateEntity.copyAndInsert(variable); if (useActivityId && sourceActivityExecution != null) { HistoricActivityInstanceEntity historicActivityInstance = findActivityInstance(sourceActivityExecution); if (historicActivityInstance != null) { historicVariableUpdate.setActivityInstanceId(historicActivityInstance.getId()); } } } }
Example #18
Source File: QueryVariableValue.java From flowable-engine with Apache License 2.0 | 5 votes |
public void initialize(VariableTypes types) { if (variableInstanceEntity == null) { VariableType type = types.findVariableType(value); if (type instanceof ByteArrayType) { throw new ActivitiIllegalArgumentException("Variables of type ByteArray cannot be used to query"); } else if (type instanceof JPAEntityVariableType && operator != QueryOperator.EQUALS) { throw new ActivitiIllegalArgumentException("JPA entity variables can only be used in 'variableValueEquals'"); } else if (type instanceof JPAEntityListVariableType) { throw new ActivitiIllegalArgumentException("Variables containing a list of JPA entities cannot be used to query"); } else { // Type implementation determines which fields are set on the entity variableInstanceEntity = VariableInstanceEntity.create(name, type, value); } } }
Example #19
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void recordVariableCreate(VariableInstanceEntity variable) { // Historic variables if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { HistoricVariableInstanceEntity.copyAndInsert(variable); } }
Example #20
Source File: SerializableType.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void setValue(Object value, ValueFields valueFields) { byte[] bytes = serialize(value, valueFields); valueFields.setCachedValue(value); super.setValue(bytes, valueFields); if (trackDeserializedObjects && valueFields instanceof VariableInstanceEntity) { Context.getCommandContext().addCloseListener(new VerifyDeserializedObjectCommandContextCloseListener( new DeserializedObject(this, valueFields.getCachedValue(), bytes, (VariableInstanceEntity)valueFields))); } }
Example #21
Source File: MybatisVariableInstanceDataManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public List<VariableInstanceEntity> findVariableInstancesByTaskAndNames(String taskId, Collection<String> names) { Map<String, Object> params = new HashMap<String, Object>(2); params.put("taskId", taskId); params.put("names", names); return getDbSqlSession().selectList("selectVariableInstancesByTaskAndNames", params); }
Example #22
Source File: MybatisVariableInstanceDataManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public VariableInstanceEntity findVariableInstanceByExecutionAndName(String executionId, String variableName) { Map<String, String> params = new HashMap<String, String>(2); params.put("executionId", executionId); params.put("name", variableName); return (VariableInstanceEntity) getDbSqlSession().selectOne("selectVariableInstanceByExecutionAndName", params); }
Example #23
Source File: HistoricVariableInstanceDataResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public RestVariable getVariableFromRequest(boolean includeBinary, String varInstanceId, HttpServletRequest request) { HistoricVariableInstance varObject = historyService.createHistoricVariableInstanceQuery().id(varInstanceId).singleResult(); if (varObject == null) { throw new ActivitiObjectNotFoundException("Historic variable instance '" + varInstanceId + "' couldn't be found.", VariableInstanceEntity.class); } else { return restResponseFactory.createRestVariable(varObject.getVariableName(), varObject.getValue(), null, varInstanceId, RestResponseFactory.VARIABLE_HISTORY_VARINSTANCE, includeBinary); } }
Example #24
Source File: DefaultHistoryManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void recordHistoricDetailVariableCreate(VariableInstanceEntity variable, ExecutionEntity sourceActivityExecution, boolean useActivityId) { if (isHistoryLevelAtLeast(HistoryLevel.FULL)) { HistoricDetailVariableInstanceUpdateEntity historicVariableUpdate = getHistoricDetailEntityManager().copyAndInsertHistoricDetailVariableInstanceUpdateEntity(variable); if (useActivityId && sourceActivityExecution != null) { HistoricActivityInstanceEntity historicActivityInstance = findActivityInstance(sourceActivityExecution, false, false); if (historicActivityInstance != null) { historicVariableUpdate.setActivityInstanceId(historicActivityInstance.getId()); } } } }
Example #25
Source File: DefaultHistoryManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void recordVariableUpdate(VariableInstanceEntity variable) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { HistoricVariableInstanceEntity historicProcessVariable = getEntityCache().findInCache(HistoricVariableInstanceEntity.class, variable.getId()); if (historicProcessVariable == null) { historicProcessVariable = getHistoricVariableInstanceEntityManager().findHistoricVariableInstanceByVariableInstanceId(variable.getId()); } if (historicProcessVariable != null) { getHistoricVariableInstanceEntityManager().copyVariableValue(historicProcessVariable, variable); } else { getHistoricVariableInstanceEntityManager().copyAndInsert(variable); } } }
Example #26
Source File: DefaultHistoryManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void recordVariableRemoved(VariableInstanceEntity variable) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { HistoricVariableInstanceEntity historicProcessVariable = getEntityCache() .findInCache(HistoricVariableInstanceEntity.class, variable.getId()); if (historicProcessVariable == null) { historicProcessVariable = getHistoricVariableInstanceEntityManager() .findHistoricVariableInstanceByVariableInstanceId(variable.getId()); } if (historicProcessVariable != null) { getHistoricVariableInstanceEntityManager().delete(historicProcessVariable); } } }
Example #27
Source File: TaskVariableResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@ApiOperation(value = "Delete a variable on a task", tags = {"Tasks"}, nickname = "deleteTaskInstanceVariable") @ApiResponses(value = { @ApiResponse(code = 204, message = "Indicates the task variable was found and has been deleted. Response-body is intentionally empty."), @ApiResponse(code = 404, message = "Indicates the requested task was not found or the task doesn’t have a variable with the given name. Status message contains additional information about the error.") }) @RequestMapping(value = "/runtime/tasks/{taskId}/variables/{variableName}", method = RequestMethod.DELETE) public void deleteVariable(@ApiParam(name="taskId", value = "The id of the task the variable to delete belongs to.") @PathVariable("taskId") String taskId,@ApiParam(name="variableName", value = "The name of the variable to delete.") @PathVariable("variableName") String variableName,@ApiParam(hidden=true) @RequestParam(value = "scope", required = false) String scopeString, HttpServletResponse response) { Task task = getTaskFromRequest(taskId); // Determine scope RestVariableScope scope = RestVariableScope.LOCAL; if (scopeString != null) { scope = RestVariable.getScopeFromString(scopeString); } if (!hasVariableOnScope(task, variableName, scope)) { throw new ActivitiObjectNotFoundException("Task '" + task.getId() + "' doesn't have a variable '" + variableName + "' in scope " + scope.name().toLowerCase(), VariableInstanceEntity.class); } if (scope == RestVariableScope.LOCAL) { taskService.removeVariableLocal(task.getId(), variableName); } else { // Safe to use executionId, as the hasVariableOnScope whould have // stopped a global-var update on standalone task runtimeService.removeVariable(task.getExecutionId(), variableName); } response.setStatus(HttpStatus.NO_CONTENT.value()); }
Example #28
Source File: ProcessInstanceVariableResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@ApiOperation(value = "Delete a variable", tags = {"Process Instances"}, nickname = "deleteProcessInstanceVariable") @ApiResponses(value = { @ApiResponse(code = 204, message = "Indicates the variable was found and has been deleted. Response-body is intentionally empty."), @ApiResponse(code = 404, message = "Indicates the requested variable was not found.") }) @RequestMapping(value = "/runtime/process-instances/{processInstanceId}/variables/{variableName}", method = RequestMethod.DELETE) public void deleteVariable(@ApiParam(name = "processInstanceId") @PathVariable("processInstanceId") String processInstanceId,@ApiParam(name = "variableName") @PathVariable("variableName") String variableName, @RequestParam(value = "scope", required = false) String scope, HttpServletResponse response) { Execution execution = getProcessInstanceFromRequest(processInstanceId); // Determine scope RestVariableScope variableScope = RestVariableScope.LOCAL; if (scope != null) { variableScope = RestVariable.getScopeFromString(scope); } if (!hasVariableOnScope(execution, variableName, variableScope)) { throw new ActivitiObjectNotFoundException("Execution '" + execution.getId() + "' doesn't have a variable '" + variableName + "' in scope " + variableScope.name().toLowerCase(), VariableInstanceEntity.class); } if (variableScope == RestVariableScope.LOCAL) { runtimeService.removeVariableLocal(execution.getId(), variableName); } else { // Safe to use parentId, as the hasVariableOnScope would have // stopped a global-var update on a root-execution runtimeService.removeVariable(execution.getParentId(), variableName); } response.setStatus(HttpStatus.NO_CONTENT.value()); }
Example #29
Source File: ExecutionVariableResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@ApiOperation(value = "Delete a variable for an execution", tags = {"Executions"}, nickname = "deletedExecutionVariable") @ApiResponses(value = { @ApiResponse(code = 204, message = "Indicates both the execution and variable were found and variable has been deleted."), @ApiResponse(code = 404, message = "Indicates the requested execution was not found or the execution does not have a variable with the given name in the requested scope. Status description contains additional information about the error.") }) @RequestMapping(value = "/runtime/executions/{executionId}/variables/{variableName}", method = RequestMethod.DELETE) public void deleteVariable(@ApiParam(name = "executionId") @PathVariable("executionId") String executionId, @ApiParam(name = "variableName") @PathVariable("variableName") String variableName, @RequestParam(value = "scope", required = false) String scope, HttpServletResponse response) { Execution execution = getExecutionFromRequest(executionId); // Determine scope RestVariableScope variableScope = RestVariableScope.LOCAL; if (scope != null) { variableScope = RestVariable.getScopeFromString(scope); } if (!hasVariableOnScope(execution, variableName, variableScope)) { throw new ActivitiObjectNotFoundException("Execution '" + execution.getId() + "' doesn't have a variable '" + variableName + "' in scope " + variableScope.name().toLowerCase(), VariableInstanceEntity.class); } if (variableScope == RestVariableScope.LOCAL) { runtimeService.removeVariableLocal(execution.getId(), variableName); } else { // Safe to use parentId, as the hasVariableOnScope would have // stopped a global-var update on a root-execution runtimeService.removeVariable(execution.getParentId(), variableName); } response.setStatus(HttpStatus.NO_CONTENT.value()); }
Example #30
Source File: TaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testNativeQuery() { assertEquals("ACT_RU_TASK", managementService.getTableName(Task.class)); assertEquals("ACT_RU_TASK", managementService.getTableName(TaskEntity.class)); assertEquals(12, taskService.createNativeTaskQuery().sql("SELECT * FROM " + managementService.getTableName(Task.class)).list().size()); assertEquals(12, taskService.createNativeTaskQuery().sql("SELECT count(*) FROM " + managementService.getTableName(Task.class)).count()); assertEquals(144, taskService.createNativeTaskQuery().sql("SELECT count(*) FROM ACT_RU_TASK T1, ACT_RU_TASK T2").count()); // join task and variable instances assertEquals( 1, taskService.createNativeTaskQuery() .sql("SELECT count(*) FROM " + managementService.getTableName(Task.class) + " T1, " + managementService.getTableName(VariableInstanceEntity.class) + " V1 WHERE V1.TASK_ID_ = T1.ID_") .count()); List<Task> tasks = taskService.createNativeTaskQuery() .sql("SELECT * FROM " + managementService.getTableName(Task.class) + " T1, " + managementService.getTableName(VariableInstanceEntity.class) + " V1 WHERE V1.TASK_ID_ = T1.ID_").list(); assertEquals(1, tasks.size()); assertEquals("gonzoTask", tasks.get(0).getName()); // select with distinct assertEquals(12, taskService.createNativeTaskQuery().sql("SELECT DISTINCT T1.* FROM ACT_RU_TASK T1").list().size()); assertEquals(1, taskService.createNativeTaskQuery().sql("SELECT count(*) FROM " + managementService.getTableName(Task.class) + " T WHERE T.NAME_ = 'gonzoTask'").count()); assertEquals(1, taskService.createNativeTaskQuery().sql("SELECT * FROM " + managementService.getTableName(Task.class) + " T WHERE T.NAME_ = 'gonzoTask'").list().size()); // use parameters assertEquals(1, taskService.createNativeTaskQuery().sql("SELECT count(*) FROM " + managementService.getTableName(Task.class) + " T WHERE T.NAME_ = #{taskName}").parameter("taskName", "gonzoTask") .count()); }