mybatis parent nested query value transfer / column plurality of parameter values passed

mybatis collection in the column pass plurality of parameter values ​​(using the parent query map value)

 


property description
column Database column names or column label alias. Passed to the same resultSet.getString (columnName) parameter name. Note: when dealing with key combinations, you can use column = "{prop1 = col1, prop2 = col2}" the syntax, a plurality of column names passed to the nested query. This will prop1 and prop2 target nested select statement to set the parameters of the object.


<-! 2. -> 
<The resultMap type = "com.Pojo" ID = "tree_map">
<column ID = "ID" = Property "ID"> </ ID>
  <-! Result field is a database ( may be as a field) which must be present and pojo ->
<Result column = "database field" property = "entity class field" javaType = "type"> </ Result>
<= Collection Property "field pojo" ofType = "com.ChildrenPojo (pojo entity class)"
column = "{ID = ID, param = the params }"
the javaType = "java.util.List" SELECT = "selectMenuChildren"> </ Collection>
</ The resultMap>

<! - 1. The inlet query tree ->
<SELECT ID = "selTree" The resultMap = "tree_map">
select *, IFNULL(#{forbidden},'') as params from table_name where 1=1
order by rank
</select>

<!-- 3.查询子 -->
<the SELECT the above mentioned id = "selChildren" resultMap = "tree_map">
<-! Note that the params field is required, otherwise it will not find the params ->
the SELECT *, IFNULL (# {} Forbidden, '') AS params WHERE pId = # ds_system_menu from {ID}
<= IF Test 'param! = null and param! = ""'>
and # param = {} param
</ IF>
Order by Rank
</ SELECT>

  The above description

 

 

 

 

Guess you like

Origin www.cnblogs.com/Ai-Hen-Jiao-zhi/p/11997126.html