Activiti 5.17-mapping rules from Activiti business object to MyBatis SQL Mapping ID

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.