@Override
	public IValue executeQuery(String query, Type type, TypeStore typeStore, boolean isCollection) throws GraphDbMappingException {
		ExecutionResult result = queryEngine.execute(query);
		if (!result.columns().isEmpty()) {
			Iterator<Node> column = result.columnAs(result.columns().get(0));
			if (isCollection) {				
				List<IValue> resultsList = new ArrayList<IValue>();			
				while (column.hasNext()) {
					Node node = column.next();					
					IValue value = type.getElementType().accept(new GraphDbValueRetrievalVisitor(node, valueFactory, typeStore));
					resultsList.add(value);
				}
				return valueFactory.set(resultsList.toArray(new IValue[resultsList.size()]));
			}
			else if (column.hasNext()) {
				Node node = column.next();
				try {
					return type.accept(new GraphDbValueRetrievalVisitor(node, valueFactory, typeStore));
				}
				catch (NotFoundException e) {
					throw new GraphDbMappingException("The type probably did not match the query result.");
				}
			}
		}
		throw new GraphDbMappingException("No query results were found.");
	}