# Problem retrieving history after changing database

**URL:** <https://forum.flowable.org/t/problem-retrieving-history-after-changing-database/3714>\
**Category:** Flowable Engine\
**Created:** [April 10, 2019, 10:58am UTC](https://forum.flowable.org/t/problem-retrieving-history-after-changing-database/3714 "2019-04-10T10:58:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TodoMary](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/todomary/32/1173_2.png) [@TodoMary](https://forum.flowable.org/u/TodoMary)\
**Post date:** [April 10, 2019, 10:58am UTC](https://forum.flowable.org/t/problem-retrieving-history-after-changing-database/3714/1 "2019-04-10T10:58:20Z")

</div>

I was working in my spring boot application with an already existing remote postgres database. Now I need to work with a different Database that I set up locally, but I have some problems. I have divided in two class the endpoints related to the definitons of processes and the ones related to the instances. The controller class with the instance endpoint uses a `HistoryService` to perform operations on the database. The class does, for example, this:

```
@Autowired
	private HistoryService historyService;
	
	@Autowired
	private ProcessInstanceService processInstanceService;
	
	
	
	/**
	 * Returns all historical process instances
	 * @return List<{@link HistoricProcessInstance}>> the list of all process instances
	 */
	@GetMapping
	public ResponseEntity<BaseResponse<List<HistoricProcessInstance>>> listAllProcessInstance() {
		
		BaseResponse<List<HistoricProcessInstance>> body = new BaseResponse<>();
		ResponseEntity<BaseResponse<List<HistoricProcessInstance>>> response = null;
		
		
		List<HistoricProcessInstance> l;
		try {
			l = historyService.createHistoricProcessInstanceQuery().list();
			
			if (CollectionUtils.isEmpty(l)) {
				body.setData(null);
				body.setMessage("No history found");
				
				response = new ResponseEntity<>(body, HttpStatus.OK);
			} else {
				body.setData(l);
				body.setMessage(Constants.OK);
				
				response = new ResponseEntity<>(body, HttpStatus.OK);
			}
		} catch (Exception e) {
			
			response = new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
		}
		return response;
	}

```

This method, for example, returns all history of process instances. Since I moved to a new DB, it returns of course the message `"No history found"`, and that’s ok.  
Now, the problem is with the process definitions controller. I have a similar method to retrieve all definitions:

```
@Autowired
	private RepositoryService repositoryService;
	
	@Autowired
	private RuntimeService runtimeService;
	
	@Autowired
	private DeploymentService deploymentService;
	
	
	/**
	 * Returns a list of process definitions (all processes that were deployed)
	 * @return a response Entity with a List<{@link ProcessDefinition}>> as body  
	 */
	@GetMapping
	public ResponseEntity<BaseResponse<?>> listProcessDefinition() {
		LOGGER.debug("retrieving process definition list");
		
		BaseResponse<List<ProcessDefinition>> body = new BaseResponse<>();
		ResponseEntity<BaseResponse<?>> response = null;
		
		List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery().list();
		
		LOGGER.debug("retrieved {} process definitions", processDefinitionList.size());
		
		if (CollectionUtils.isEmpty(processDefinitionList)) {
			body.setMessage("There are no processes deployed.");
			response = new ResponseEntity<>(body, HttpStatus.NO_CONTENT);
		} else {
			body = new BaseResponse<>(Constants.OK, processDefinitionList);
			response = new ResponseEntity<>(body, HttpStatus.OK);
		}
		
		return response;
	}

```

The problem is that, in this case, if I perform a GET to this endpoint and the method is called, the browser doesn’t show anything, the page is not loaded, no message is shown. So I thought it was an empty database problem, but I don’t know how to fix it… My question is: why, in this case, since the `processDefinitionList` is empty, no message is shown on the browser and with the process instances is shown. Is it because one uses HistoryService and one RepositoryService? In what are they different? How can I manage this?  
To clarify: to change my database, all I did was changing connection informations inside `application.properties` file

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [April 15, 2019, 10:48pm UTC](https://forum.flowable.org/t/problem-retrieving-history-after-changing-database/3714/2 "2019-04-15T22:48:23Z")

</div>

Hey @TodoMary,

I presume that the browser does not show anything when retrieving all definitions, because you are using the `HttpStatus.NO_CONTENT`. In your first example you are using `HttpStatus.OK`.

For your question about the difference between the `HistoryService` and the `RepositoryService`.

The `HistoryService` and the `RuntimeService` are services that are used to query process instances / tasks. Every process instance in Flowable has a corresponding process definition. The process definition is actually the BPMN XML that you have deployed. The definitions are immutable and can be deployed / queried via the `RepositoryService`.

You can think of it in the following way:

- `RepositoryService` - static immutable data that cannot change. Every new deployment actually creates a new row with a new version for the same key
- `HistoryService` / `RuntimeService` - data running based on a certain definition. This data is mutable and is where the execution of the process occurs.

Cheers,  
Filip

---

<div class="post-metadata">

**Author:** ![TodoMary](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/todomary/32/1173_2.png) [@TodoMary](https://forum.flowable.org/u/TodoMary)\
**Post date:** [April 16, 2019, 10:50am UTC](https://forum.flowable.org/t/problem-retrieving-history-after-changing-database/3714/3 "2019-04-16T10:50:08Z")

</div>

Thank you very much @filiphr !
