2013年9月13日星期五

Mybatis grouping problem (group by)

in ibatis has an attribute of resultMap is group-by = ' field ' , but using mybatis found resultMap do not have this property , and ask how grouping of ? Do not want to write in an SQL statement group by xxx. Because it involves too many SQL
------ Solution ---------------- ----------------------------
configure an id attribute on the line, and groupby same, such as


------ For reference only ----- ----------------------------------
mybatis can not seem to use groupBy keyword
--- --- For reference only ---------------------------------------


This will be grouped according to the ID you ?
------ For reference only -------------------------------------- -
two approaches
1, for example, if you want to use to group by other complex sql, mybatis own syntax can not meet , you can form a complex sql view , and then view as a table, with autogenous tools to mysql generate the corresponding code.
2, using mybatis architecture , imitating autogenous code , write their own respective mapper.xml, entity, interface

generally recommended first approach , simple and easy to manage
------ For reference only ----------------------- ----------------
buddy, you solve it ? According to the above method does not work ah add id

没有评论:

发表评论