Mybatis dynamically obtains the field value (you do not need to create a javabean), mybatisjavabean

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.