Mybatis study notes - the input parameters parameterType, Mybatis call a stored procedure

Input parameters: parameterType (two values ​​Symbol)
1. The type of simple type
the difference:
    (1) may be any value # {}
        $ {Vaue} ---> identifier value is only
    (2) # {} to automatically add a String '' ---> automatic conversion
        $ {} Is output ---> adapted dynamic fields for dynamic ordering
    (3) # {} prevent sql injection
        {} $ Does not prevent
In common:
    (1) can get the value (nested type objects) of
 
2. Object Types 
    Attribute name} {#
    Attribute name} {$ ---> identifier is a name attribute, eg: stuno
 
Enter the object as HashMap:
    The map used in the key value matches the placeholder # {name}, if the matching succeeds, with the map value replaces the placeholder.
 
MyBaties call a stored procedure
<! - query a year by the total number of calls stored procedures  statementType = "CALLABLE "
    Input parameters must HashMap ->
    <select id="queryCountByGradeWithProcedure" statementType="CALLABLE" resultType="int" parameterType="HashMap">
        {
             call queryCountByGradeWithProcedure(
                #{gName,jdbcType=VARCHAR,mode=in},
                #{sCount,jdbcType=INTEGER,mode=out}
            )
        }
    </select>
In use, () method of the input parameter value passed by the HashMap put, get the value of the output parameter by the get () method.
Note that version issue a jar.
<TransactionManager type = "JDBC" />, must be manually commit CRUD

Guess you like

Origin www.cnblogs.com/ghlz/p/12222798.html