Mybatis dynamically obtains the field value (you do not need to create a javabean), mybatisjavabean
Recently, we have encountered the following requirement:
You can use a custom template to select the fields to be queried and displayed dynamically.
Premise: the database has a table with more than 400 fields.
Requirement: You can customize a template at the front-end. A template may correspond to x fields and can be customized (for example, you have defined an RNC traffic model). You can click the RNC traffic model, you need to query the data of the fields you just defined.
Technical Implementation: Use mybatis as the data layer (mybatis query principle: the queried data is encapsulated into a map, and the field name is used as the key value, and the data is used as the value)
Specific implementation:
The configuration of mybatis. xml is as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE mapper PUBLIC "-// mybatis.org//DTD Mapper 3.0 // EN"
Http://mybatis.org/dtd/mybatis-3-mapper.dtd>
<Mapper namespace = "com. huawei. galaxy. mybatis. dao. IDeepInsightGetDataMapper">
<Select id = "queryFlowData" parameterType = "Map" resultType = "Map">
<! [CDATA [
SELECT * FROM TABLE
]>
WHERE 1 = 1
<If test = "param! = Null and param! = ''">
.........................
</If>
</Select>
</Mapper>
Dao layer interface definition:
Public interface IDeepInsightGetDataMapper extends IBenchMarkMapper {
/**
* Function: Query traffic height data.
* @ Param: PASS Parameters
* @ Return
*/
Public List <Map <String, Object> queryFlowData (Map <String, Object> param );
}
Service layer interface definition:
Public interface IDeepInsightService {
Public List <Object> getData (Map <String, Object> paramMap, TableParam pageParam );
}
Obtain 【]Springmvc mybatis Integrated Framework source code bootstrap html5 mysql oracle spring