Analysis Configuration Mapper configuration file sql an example: Mybatis learning

mybatis study documents: by Chunxiao recommended https://blog.csdn.net/luanlouis/article/details/40422941

Example:

 

Resolution:

<= IF Test "! = null min_salary"> 
    		WHERE the SALARY <# {min_salary, the jdbcType = DECIMAL} 
</ IF> 

IF Test = "! = null min_salary": If the representative min_salary is empty (min_salary no value) which is not spliced statement (not behind the implementation where)
where SALARY <# {min_salary, jdbcType = DECIMAL}: SALARY less than the representative value passed in your min_salary, jdbcType The parameters representing the min_salary; 

# {}: Remove your behalf passed in parameter value corresponding min_salary

 

 

 

 


  <select id="selectByMinSalary" resultMap="BaseResultMap" parameterType="java.util.Map" >
    select 
    	EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, SALARY
    	from LOUIS.EMPLOYEES
    	<if test="min_salary != null">
    		where SALARY < #{min_salary,jdbcType=DECIMAL}
    	</if>
  </select>

Guess you like

Origin www.cnblogs.com/shay/p/12176549.html