Both of these frameworks are written by a great God. Used to do single-table additions and deletions, Shuangshuang. But complex queries do not yet know how to use them, so I also write service maperr in the traditional way, write SQL to handle complex queries, and query with multiple tables. Its complex query is a bit like hiberate's conditional query. But hibernate has not written for a long time, have forgotten.Framework for Universal Mapper
Idea ran an error while running the SSM projectOrg.apache.ibatis.binding.BindingException:Invalid bound statement (not found)Cause: There is no mybatis configuration file in target after deployment *.xmlWORKAROUND: Force the *.xml file to be published together with Maven in Pom.xmlIntelliJ idea can't find mapper through MAVEN building the SSM project
The SQL file in MyBatis is not directly written for greater than or equal to or less than equals. = or 1. Escape by symbol:Escape character
Less than sign
gt;
>
Greater than sign
amp;
And
apos;
’
Single quotation marks
quot;
"
Double quotes
2. By identifier:UseSELECT Newsedit,newsid, newstitle from Shoppingguide WHERE 1=1 and Newsday > #{starttime} and Newsd
Reprinted from: http://blog.csdn.net/szwangdf/article/details/26714603By default, using the #{} syntax, MyBatis produces preparedstatement statements, and safe settings PreparedStatement parameters, which mybatis perform the necessary security checks and escapes.Example 1:Execute Sql:select * from emp WHERE name = #{employeename}Parameter: Employeename=>smithParsed after executing sql:select * from emp where name =?Execute Sql:select * from emp WHERE name = ${employeename}Parameter: EmployeeName
First, create a MAVEN project with Eclipse.Second, under the Pom.xml file, add the following plug-in configuration:xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" > //maven.apache.orgtruetrueThird, find the configurationfile tag from Pom.xml, and follow the path on the label (Src/main/resources/generator.xml) into the core configuration file of the following generated code, Generator.xml:Four, cmd Open the DOS window, to the root path of the proje
1. Download the package addresshttp://download.csdn.net/detail/u012909091/72060912. Download and unzip the file to any directory3. Delete all files under mybatis-generator-core-1.3.2\mybatis-generator-core-1.3.2\lib\src 4. Modify the configuration file Mybatis-generator-core-1.3.2\mybatis-generator-core-1.3.2\lib\generatorconfig.xml file"Jdbc:mysql://localhost:3306/generator" userid= "root" password= "249832" >tablename= "test" domainobjectname= "test" enablecountbyexample= "false" enableupdateb
parametertype: Parameter type, can be omitted, gets the value of the self-increment primary key: MySQL supports the self-increment primary key, the self-increment primary key value obtains, MyBatis also uses Statement.getgenreatedkeys (); Usegeneratedkeys= "true"; Gets the primary key value policy using the self-increment primary key Keyproperty Specifies the corresponding primary key attribute, that is, after MyBatis obtains the primary key value, encapsulates the value
the thin_pool_autoextend_percent for when thin pool autoextension occurs.
The value ' s setting is the perentage of space to increase the thin pool (+ disabled)
Thin_pool_autoextend_percent = 20
8.Check your work, your docker-thinpool.profile file should appear similar to the following:
An example/etc/lvm/profile/docker-thinpool.profile file:
Activation {Thin_pool_autoextend_threshold=80Thin_pool_autoextend_percent=20}9. Submit the LVM configuration file
$ sudo lvchange--metadataprofile docke
In the MyBatis configuration file, note that the Pagehelper plugin is written in front of the general mapper
Otherwise it will be reported
Org.mybatis.spring.MyBatisSystemException:nested exception is Org.apache.ibatis.builder.BuilderException:Error Invoking SQLProvider Method (Com.github.abel533.mapper.MapperProvider.dynamicSQL). Cause:java.lang.InstantiationException:com.github.abel533.mapper.MapperProviderAt Org.mybatis.spring.MyBatisExceptionTran
); SYSTEM.OUT.PRINTLN (user); }}
Configuration Mode 2Enable the spring scanner to comment out the original usermapper beanMapper Configuration Mapperfactorybean: Generate proxy objects based on mapper interface - - mapper batch scan, scan out the Mapper interface from the Mapper package,
Mybatis framework 3: dao layer development, Mapper dynamic proxy development, and mybatismapper
Here is the most basic building: http://www.cnblogs.com/xuyiqing/p/8600888.html
Next we achieve a simple addition, deletion, modification, query: http://www.cnblogs.com/xuyiqing/p/8601506.html
However, it is found that the code is too repetitive.
Next we will integrate and implement DAO development:
I. Original DAO development:
package dao;import pojo.Use
1, create the Mybatis-config.xml file, in the file to complete and database connection settings operationXML version= "1.0" encoding= "UTF-8"?>DOCTYPE configuration Public "-//mybatis.org//dtd Config 3.0//en" "Http://mybatis.org/dtd/mybatis-3-config.dtd">Configuration>PropertiesResource= "Db.properties"/>Typealiases>Two methods to use, it is recommended to use the second--PackageName= "Com.huawei.bean"/>Typealiases>EnvironmentsDefault= "Development">EnvironmentId= "Development">Configuring trans
Colleagues for help, said the restart of Debian, the system hangs.Report the following error```Loading, please wait .../dev/mapper/debian--vg-root contains a file system with Errors,check the file system./dev/mapper/debian-vg-root:Inodes that were part of a corrupted orphan linked list found./dev/mapper/debian--vg-root:unexpected inconsistency; RUN fsck manually.
Spring Mapper injection into service failed solution
Background: Some time ago in the research Springboot, and the company's small projects successfully used Springboot transformation, for the springboot of the agreement than the concept of configuration, it is agreed that the project structure and code more concise and elegant. This time is not too busy, so the project is ready to change, now the project with the company's traditional SSM, the projec
Mybatis uses mapper code to integrate with Spring (1)Introduction
The two ORM frameworks named javasselink and Hibernate, which have been used in previous java projects, are now implemented using Mybatis. Of course they have their own advantages and disadvantages. Sometimes, two frameworks can be used together in a project. In a project, technical selection is very important. Mybatis is a persistent layer framework and is a top-level project under apa
1. Mapper ClassFirst of all, there are four methods for the Mapper class:(1) protected void Setup (context context)(2) Protected void map (keyin key,valuein value,context Context)(3) protected void Cleanup (context context)(4) public void run (context context)The Setup () method is typically used to load some initialization work, such as a global file \ A link to a database, and so on; the cleanup () method
1. First define an entity User type that receives the data, and a userquery type for the input parameter.1 Public classUser {2 Public intID;3 PublicString username;4 PublicDate birthday;5 PublicString sex;6 PublicString address;7 }8 Public classUserQuery {9 PrivateString Orderbyclause;Ten PrivateListOredcriteria; One Public voidAddusernamelike (String username) { AOredcriteria.add (NewCriteria ("username like", username)); - } - Public voidAddsexg
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.