In MyBatis, if it is too unfriendly to write a full name for each configuration class, we can no longer need to specify the complete package name by configuring the alias in the master configuration file.
Basic usage of aliases:
But if every entity class is a bit of a hassle, then we can specify the package name directly, MyBatis will automatically scan the JavaBean under the specified packet, and the default setting is an alias, the default name is: JavaBean An unqualified class name with the
Hibernate+mysql Association Mapper encounters Java.lang.StackOverflowError exceptionCause the output of one side of a property corresponding to an attribute in the ToString method of a multi-party when making an association mapLike what: a party to:@Entity@Table (name = "App", schema = "", Catalog = "Game")public class Appentity {@Id@Column (name = "AppId")Private String appId;@Basic@Column (name = "AppName")Private String AppName;@Basic@Column (name
1. MapReduce Code EntryNew // sets the MapReduce input format job.waitforcompletion (true);2. InputFormat Analysis Public Abstract class Inputformat { // Gets the shard of the input file, is only a logical shard, and does not have a physical shard public Abstract list getsplits (jobcontext context); // Create Recordreader to read Data from Inputsplit Public Abstract Recordreader Createrecordreader (inputsplit split,taskattemptcontext context);}Different InputFormat will imp
Mybaits3 source code analysis (2): Scan Mapper to associate with spring IOC container, mybaits3ioc
First, let's talk about how mapper is configured to an object.
All interfaces that implement classes specified by markerInterface under basePackage will be scanned and parsed. Mapperscannerproceser implements the BeanDefinitionRegistryPostProcessor (BeanDefinitionRegistry postprocessor, think about Spring AOP
How to determine Mapper quantity for Hadoop-2.4.1 Learning
The advantage of MapReduce framework is that it can run mapper and reducer tasks in parallel in the cluster. How can we determine the number of mapper and reducer tasks, or how does Hadoop programmatically control the number of ER er and reducer started by jobs? In the
Intellij idea plug-in development-Quickly locate SQL IN THE mybatis mapper file and intellijmybatis
Intellij idea provides openApi, through which we can develop our own plug-ins to improve work efficiency. You can directly paste a link here to get started with the demo. http://www.jianshu.com/p/2427e4cfd3e9, you can also find it online .. I use intellij idea 2017 and jdk 1.8 or above.
Step 1: New project, select IntelliJ Plaltform Plugin,
Click Next,
testing the code we wrote.There are some problems with this development:There is a lot of duplicate code in the implementation class of the 1.dao interface, which increases the programmer's workload.2. In the implementation class, the Sqlsession method hard-encodes the statement ID (where "Test.finduserbyid" is the ID of statment) when invoking the SQL statement in the map file. 3. The variable passed in when the Sqlsession method is called, because the Sqlsession method uses generics, even
Currently MyBatis in addition to the SQL can be configured through XML, but also through the form of annotations to configure SQL, this article mainly describes how MyBatis is handling annotated SQL mapping, through the source code analysis processXML configurationParsing process private void Mapperelement (xnode parent) throws Exception {//If the Mapper node is configured in the configuration (parent! = NULL) { For (XNode Child:parent.getCh
When defining a Mapper interface (Userdao), we do not need to implement this class, but Sqlsession.getmapper () eventually returns an object that implements the interface. This object is implemented by MyBatis using the dynamic proxy of JDK. Here we will introduce the generation process of this proxy object and the implementation process of its method. The mapper code object's build Process Defaultsqlsessio
This article immediately follows the job flow: the factors that determine the number of maps ,after the job submission is completed, is handled by the Mapper class. 1). The setup () and Cleanup () two methods in the Mapper class are responsible for the initialization and cleanup of the map task ( default is an empty implementation )2). The Run () method in the Mapper
In the actual application, there will be more mapper. If each new mapper is added, it will be inconvenient to add the corresponding configuration file to the Sqlmapconfig.You can create a new package, place Mapper.java underneath it, and place the same named Mapper.xml under it.In this way, you can use Be aware of the. Java and. XML naming, and Mapper.xml namespace.First,
Following the previous example project Http://www.cnblogs.com/EasonJim/p/7083165.html, using the Configdecoratormapper Mapper, the page under the specified directory is the same as the template page.On the use, just set two places, no configuration on the basic page.1, Decorators.xmlXML version= "1.0" encoding= "UTF-8"?>DecoratorsDefaultDir= "/decorators"> Decoratorname= "Basic-theme"page= "basic-theme.jsp"> Decorator>Decorators>2, Sitem
Because DAO development, will create entity class object every time, will pass in fixed query value such as ID, there is hard coding problem, so adopt mapper dynamic proxy (do not create entity class object, need interface only, automatically generate by mapper) as before MyBatis (a) step, However, you need to make changes to the Mapper.xml file:Namespace: must be the full path of the interface class (ID: M
1. Create a new MyBatis folder in the src/main/resources/directory and put the Xxx.xml file in the folder2. Configure in the Application.yml file:MyBatisConfigurationMapunderscoretocamelcase:trueMapperlocations:mybatis/*mapper.xml3, in the DAO interface file annotated @mapper, note that the interface method on the SQL statement to remove@Mapper Public Interfacemrinfomapper{/*** Query Mr Information on condi
.
@Case
Method
The value of the singleton instance and its corresponding mapping. Properties: Value,type,results. The Results property is an array of results, so this annotation is similar to the actual resultmap, as specified by the following Results annotation.
@Results
Method
A list of result mappings that contains details of how a particular result column is mapped to a property or field. Property: Value, which is an array of Result annotatio
); 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
you are mapping. When mapping them, you should keep their performance in the brain. The unit tests and performance tests that your app will have to do before it finds the best method. Fortunately MyBatis allows you to change your mind later without having a small (or any) effect on your code.Advanced associations and collection mappings are a matter of depth. The documentation can only be introduced to you here. With a little connection, you will soon know how to use them.Identification device
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.