Before I saw Sails.js's waterline provided a declarative relational object with a DB mapper, the surprise of heaven, can be said to greatly improve the efficiency.Using the Waterline object-relational model, users can define relational databases directly using the JavaScript language, meaning that we no longer need to declare the model as in the Java environment, and then the specific relational operations require the user to handle the code in the bu
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
Mybatis BASICS (2) ---- development of the original dao and mapper proxy, mybatismapper
Undertake the previous mybatis entry-level BASICS (1)
After reading the previous article, I can see that there are a lot of repeated code in MybatisService, which does not seem very clear, but the first time I write it like that, I want to know how to execute mybatis, bitter before sweet!I. Original dao Development Method
Summary: 1. Compile the dao interface and d
The previous post summarizes some of the drawbacks of MyBatis's approach to using primitive DAO, and we certainly won't use it, so how do we develop DAO in MyBatis? As described in title, this blog post mainly summarizes the steps to develop DAO using the Mapper proxy method.When developing DAO using the Mapper proxy method, programmers only need to do two things:
Need to write Mapper.xml map
The use and principle analysis of mapper mapping configuration in Publictype, sqlsession sqlsession) { FinalMapperproxyfactory) Knownmappers.get (type); if(Mapperproxyfactory = =NULL) { Throw NewBindingexception ("type" + Type + "is not known to the Mapperregistry.")); } Try { returnmapperproxyfactory.newinstance (sqlsession); } Catch(Exception e) {Throw NewBindingexception ("Error getting mapper
MyBatis General Mapper provides a basic CRUD API that omits time to write a large amount of basic code or even advanced code, which is convenient and efficient. You can refer to the Generic mapper documentation
Springboot Integrated Universal Mapper, first of all, adding dependencies
Then write the Mybatismapper configuration
Package com.xbz.web.com
existence of dispatcherservlet greatly reduces the coupling between the components2.HandlerMapping Processor MapperRecord URL and processor mappings in the form of annotations, XML configuration, etc.3.HandLer processorBack-end controllers (popular point: The business code written by the controller layer). Processing a user's request4.HandlerAdapter Processor AdapterThe processor is executed through the Handleradapter, which is an application of the adapter pattern that can be performed on more
MyBatis Mapper XML file-mapping and parameters
The true strength of MyBatis lies in its mapping statement and its magic. Because of its exceptional power, the mapper's XML file appears relatively simple. If you compare it to a JDBC code that has the same functionality, you'll immediately find that you've skipped nearly 95% of the code. MyBatis is built for SQL and is better than normal methods.
The SQL mapping file has a few top-level elements (in t
Configuring log4j is relatively straightforward, such as logging of this mapper interface needs to be logged:Package Org.mybatis.example;public interface Blogmapper {@Select ("select * FROM blog WHERE id = #{id}") Blog Selectblog (int id);}As long as a file named log4j.properties is created in the app's classpath, the specific contents of the file are as follows:# Global Logging Configurationlog4j.rootlogger=error, stdout# MyBatis logging configuratio
Development specification:Mapper interface development method only need to program ape to write Mapper interface (equivalent to DAO interface),Dynamic proxy objects that are created by the MyBatis framework based on the interface definition.The method body of the proxy object is the same as the DAO interface implementation class method.Mapper interface development is subject to the following specifications:The namespace in the 1.mapper.xml file is the
Original address
Although MyBatis is very convenient, but want to write all the mapper still very tiring, fortunately mybatis the official introduction of automation tools, can be based on the database and the definition of a good configuration directly generated DAO layer and all the following code, very convenient.First WOM We build a maven project, I don't write it in detail here.Mybatis-generator Use configuration
Open the Pom.xml file and add 3
Summary after reading:O/R Mapping is the relational object ing.Databases are used to map classes and data tables.The advantage is that it can automatically generate an object to save, delete, and read SQL statements.Currently, ado.net objectspaces does not support Chinese queries. The version only supports SQL Server 2000 or later;Looking forward to ADO. net2.0
Original article:What is o/R mapper?
Author: Huo www.aspcool.com time: 13:35:56 views:
Tags: turn off CTO replacement batch Scanner EXCE EFAULT not LSEI. Overview of SqlsessionIn MyBatis, you can use Sqlsessionfactory to create sqlsession. Once you have a session, you can use it to execute the mapping statement, commit or rollback the connection, and finally, when you no longer need it, you can close the session. After using mybatis-spring, you no longer need to use sqlsessionfactory directly, because your bean can be injected through a thread-safe sqlsession, automatically commit
1. The configuration of the front controller Dispatcherservlet is configured in Web. XML to be the same as the servlet configuration1) contextconfiglocation configuration Sprimgmvc loaded configuration file (Configuration Processor mapper, adapter, etc.) if Contextconfiglocation is not configured, the default load is/web-inf/ Servlet name-servlet.xml (springmvc-servlet.xml)2)The first type: *.action, accessed with. Action ends resolved by Dispatcherse
1. Configure the note Mapper and adapter. -- Bean class="Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" /> -- Bean class="Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter" />However, in the actual development, the annotations of the adapter and mapper configuration is often used to note-driven:
Using Mvc:annotation-driven in
Mrunit can take less time and can test mapper and reducer separatelySteps:1, the use of Mrunit test mapper and Reducer2, the implementation of the MapReduce code localization test3. Using Hadoop logs4. Track execution metrics by counterThe process of testing mapper1, instantiate the Mapdirver class, as the test mapper is parameterized2. Call the Withmapper method
First, note: version issuesspring3.2 Previous versions, the annotated mapper and adapter used the following two classes.Org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping. class Org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter. classIn the new version of the source code, you can see the following comments:The following classes are used in the 3.2 included and later versions:Org.springframework.w
Prerequisites: already integrated MyBatisCode generation steps:
Add dependencyDependency> groupId>Tk.mybatisgroupId> Artifactid>Mapper-spring-boot-starterArtifactid> version>1.1.4version>Dependency>Dependency> groupId>Org.mybatis.generatorgroupId> Artifactid>Mybatis-generator-coreArtifactid> version>1.3.6version>Dependency>
Create a class with the main method, the code is as follows PackageCom.ghaien.generator;ImportOrg.mybatis
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.