The business entity layer of Activiti uses PersistentObject to pass data to the data layer;
MyBatis executes the SQL logic using the ID in mapping;
This article describes the mapping rules from Activiti persistentobject to MyBatis SQL ID.
I. The relationship between data layers and data
Second, PersistentObject object
Third, MyBatis corresponding SQL ID
1. Insert
<insert id= "Insertprocessdefinition" parametertype= " Org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity "> ... </insert>
<insert id= "insertattachment" parametertype= "org.activiti.engine.impl.persistence.entity.AttachmentEntity" > ... </insert>
2. Update
<update id= "updateattachment" parametertype= "org.activiti.engine.impl.persistence.entity.AttachmentEntity" > ... </update>
<update id= "Updateprocessdefinition" parametertype= " Org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity "> ... </update>
3. Delete
<delete id= "Deleteprocessdefinitionsbydeploymentid" parametertype= "string" > ... </delete>
<delete id= "deleteattachment" parametertype= "org.activiti.engine.impl.persistence.entity.AttachmentEntity" > ...
Iv. Mapping Rules
1, String prefix = "Insert";
2, Class persistentobjectclass = Org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity.class
3, String statement = prefix + persistentobjectclass.getsimplename (); Value is: insertprocessdefinitionentity
4, statement = statement.substring (0, Statement.length ()-6); Value is: insertprocessdefinition
5. Statement = "Insertprocessdefinition" corresponds to the ID in the 1th insert above.
So, as long as you know the method and the Action object, you can find the SQL ID of MyBatis and execute the SQL.
The relevant code is as follows:
Public String getinsertstatement (PersistentObject object) {return getstatement (Object.getclass (), Insertstatements, "Insert"); } public String Getupdatestatement (PersistentObject object) {return getstatement (Object.getclass (), Updatestatements, "Update"); } public String getdeletestatement (class<?> persistentobjectclass) {return getstatement (Persistentobjectclass, deletestatements, "delete"); } public String getselectstatement (class<?> persistentobjectclass) {return getstatement (Persistentobjectclass, Selectstatements, "select"); } private String Getstatement (class<?> persistentobjectclass, map<class<?>,string> cachedstatements, String prefix) {string statement = Cachedstatements.get (Persistentobjectclass); if (statement!=null) {return statement; } statement = prefix + persistentobjectclass.getsimplename (); statement = statement.substring (0, Statement.length ()-6); Cachedstatements.put (Persistentobjectclass, statement); Return statement; }
Activiti 5.17-mapping rules from Activiti business object to MyBatis SQL Mapping ID