AnsweredAssumed Answered

Need help with configuring custom SQL.  Getting error for MapperRegistry

Question asked by navonodt on Aug 11, 2017
Latest reply on Aug 11, 2017 by navonodt

I am trying to configure a custom mybatis query and missing something.  

 

I created my interface 

 

package com.activiti.mappers;

import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CustomMybatisMapper {

@Select("SELECT ID_ FROM ACT_RE_PROCDEF WHERE KEY_ = #{key}")
String loadProcessDefinitionIdByKey(String key);
}

 

I added an xml file under src/main/resources/mappers/CustomMybatisXmlmapper.xml

 

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

 

<mapper namespace="com.activiti.mappers.CustomMybatisMapper">

 

    <!-- SELECT ALL PROCESS DEFINITION ID -->

    <select id="selectProcessDefinitionDeploymentIdByKey" parameterType="String" resultType="String">

        SELECT DEPLOYMENT_ID_ FROM ACT_RE_PROCDEF WHERE KEY_ = #{value}

    </select>

 

</mapper>

 

I added an application.properties entry 

 

spring.activiti.customMybatisXMLMappers[0] = mappers/CustomMybatisXmlMapper.xml

spring.activiti.customMybatisMappers[0] = com.activiti.mappers.CustomMybatisMapper

 

I put those in the activiti-app.properties too.

 

The one thing I cannot figure out is this part of the directions.

 

<property name="customMybatisMappers"> <set> <value>org.activiti.standalone.cfg.MyTestMapper</value> </set> </property>

 

which in my case would be 

 

<property name="customMybatisMappers"> <set> <value>com.activiti.mappers.CustomMybatisMapper</value> </set> </property>

 

 

Where does this go????   I was also investigating doing the configuration using the 

ProcessEngineConfigurationConfigurer

 

when I run the following code 

String processDefinitionId = managementService.executeCustomSql(new AbstractCustomSqlExecution<CustomMybatisMapper, String>(CustomMybatisMapper.class) {

            @Override

            public String execute(CustomMybatisMapper customMybatisMapper) {

                return customMybatisMapper.loadProcessDefinitionIdByKey("myprocesskey");

            }

        });

I get:

org.apache.ibatis.binding.BindingException: Type interface com.activiti.mappers.CustomMybatisMapper is not known to the MapperRegistry.

Outcomes