Mybatis + spring mvc perfect integration solution query, save, update, delete automatically generated

Source: Internet
Author: User

Brief Introduction to JEECG [J2EE Code Generation] Code Generation: generate corresponding beans, services, Dao, Action, XML, JSP, etc. based on the table, and use the add, delete, modify, and query functions directly, the quick development of jeecg-mybatis-framework is implemented, and mainstream frameworks such as SpringMVC and Mybatis are used to support databases: Mysql, Oracle10g frontend: Jquery and Easyui technologies. the JS package is simple and easy to operate. permission: controls the menu and buttons. displays menus and buttons Based on the logon user permissions. intercept: blocks all unauthorized URLs to prevent manual sending of HTTP requests and ensure system completeness. java code <? 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 =" scott. dao. demo. JeecgNoteDao "> <! -- Result Map --> <resultMap id = "BaseResultMap" type = "scott. entity. demo. jeecgNote "> <result column =" id "property =" id "/> <result column =" title "property =" title "/> <result column =" content "property = "content"/> <result column = "crtuser" property = "crtuser"/> <result column = "crtuser_name" property = "crtuser_name"/> <result column = "create_dt" property = "create_dt"/> <result column = "deleted" property = "delete D "/> </resultMap> <! -- Jeecg_note table all fields --> <SQL id = "Base_Column_List"> id, title, content, crtuser, crtuser_name, create_dt, deleted </SQL> <! -- Query condition --> <SQL id = "Example_Where_Clause"> where 1 = 1 <trim suffixOverrides = ","> <if test = "id! = Null and id! = ''"> And id =#{ id} </if> <if test = "title! = Null and title! = ''"> And title =#{ title} </if> <if test = "content! = Null and content! = ''"> And content =#{ content} </if> <if test = "crtuser! = Null and crtuser! = ''"> And crtuser =#{ crtuser} </if> <if test = "crtuser_name! = Null and crtuser_name! = ''"> And crtuser_name =#{ crtuser_name} </if> <if test = "create_dt! = Null and create_dt! = ''"> And create_dt =#{ create_dt} </if> <if test = "deleted! = Null and deleted! = ''"> And deleted =#{ deleted} </if> </trim> </SQL> <! -- Insert record --> <insert id = "add" parameterType = "Object"> <selectKey resultType = "java. lang. integer "order =" AFTER "keyProperty =" id "> SELECT LAST_INSERT_ID () </selectKey> insert into jeecg_note (id, title, content, crtuser, crtuser_name, create_dt, deleted) values (# {id}, # {title}, # {content}, # {crtuser}, # {crtuser_name}, # {create_dt}, # {deleted }) </insert> <! -- Modify Record Based on id --> <update id = "update" parameterType = "Object"> update jeecg_note set title =#{ title}, content =#{ content }, crtuser =#{ crtuser}, crtuser_name =#{ crtuser_name}, create_dt =#{ create_dt}, deleted =#{ deleted} where id =#{ id} </update> <! -- Modify the record and only modify fields not empty --> <update id = "updateBySelective" parameterType = "Object"> update jeecg_note set <trim suffixOverrides = ", "> <if test =" title! = Null "> title =#{ title}, </if> <if test =" content! = Null "> content =#{ content}, </if> <if test =" crtuser! = Null "> crtuser =#{ crtuser}, </if> <if test =" crtuser_name! = Null "> crtuser_name =#{ crtuser_name}, </if> <if test =" create_dt! = Null "> create_dt =#{ create_dt}, </if> <if test =" deleted! = Null "> deleted =#{ deleted}, </if> </trim> where id =#{ id} </update> <! -- Delete record --> <delete id = "delete" parameterType = "Object"> delete from jeecg_note where id =#{ id} </delete> <! -- Query the announcement by id --> <select id = "queryById" resultMap = "BaseResultMap" parameterType = "Object"> select <include refid = "Base_Column_List"/> from jeecg_note where id = # {id} </select> <! -- Total announcement list --> <select id = "queryByCount" resultType = "java. lang. integer "parameterType =" Object "> select count (1) from jeecg_note <include refid =" Example_Where_Clause "/> </select> <! -- Query the announcement list --> <select id = "queryByList" resultMap = "BaseResultMap" parameterType = "Object"> select <include refid = "Base_Column_List"/> from jeecg_note <include refid = "Example_Where_Clause"/> <if test = "pager. orderCondition! = Null and pager. orderCondition! = ''" >$ {Pager. orderCondition} </if> <if test = "pager. mysqlQueryCondition! = Null and pager. mysqlQueryCondition! = ''" >$ {Pager. mysqlQueryCondition} </if> </select> </mapper>

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.