dotnet Programmer's Java Crawl Pit Tour (ii)

Source: Internet
Author: User
Tags bulk insert dotnet

I wrote a lot of it, and finally it was all erased. Hey ~

Words to the positive, recently because of the development of a lot of things, so the renewal of the late, has been learning, but the sense of efficiency is not very high, this is not right, reflect on, from this blog post start, play the spirit of it.

MyBatis Batch New numbers:

Bulk INSERT: Likeness we have the need to insert numbers in batches, such as inserting 100 of numbers, and the traditional approach is to use the For loop 100 times, but in this way there are serious efficiency problems that require a frequency of access.

The best way to solve this is to use MyBatis to support Bulk INSERT configuration and language.

Need to connect the string Hishinuma Setup allowmultiqueries=true in the repository

Access to Sqlsessionfactory

public static sqlsessionfactory sqlsessionfactory = null; public static Sqlsessionfactory Getsqlsessionfactory () {
if (sqlsessionfactory = = null) {
String resource = "Mybatis-config.xml";
try {
Reader reader = Resources.getresourceasreader (Resource);
Sqlsessionfactory = new Sqlsessionfactorybuilder (). build (reader);
} catch (IOException e) {
E.printstacktrace ();
}
}
return sqlsessionfactory;
} public void Testbatchforexecutor ()
{
Sqlsession sqlsession = This.getsqlsessionfactory (). Opensession ( Executortype.batch);        Personmapper personmapper = Sqlsession.getmapper (Personmapper.class); for (int i = 0; I <10000; i++)
{
Personmapper.addperson (New User ("Jerry", "BJ"));
       }        sqlsession.commit ();          sqlsession.close ();   } mybatis suspend Cutter page:  Use the Pagehelper plug-in page, detailed introduction to the Pagehelper GitHub, which is no longer baggage.  However, the use of plug-ins may modify the bottom design, using the need to be cautious plug-in generation of the layer agent to the responsibility of the image, the use of reflection machine plug-in editor to consider the full, special is a number of plug-in layer agent. Or is it better to recommend the use of a traditional SQL sentence, which is a little more basic than the basics.     spring Mvc:springmvc is a product of the spring framework, and the best way to present the MVC design framework, and the spring framework can be used well, without the need to integrate core components: Dispatcherservlet: Front controller, also the core of the entire SPRINGMVC framework handlemapping: Map to Handler Handler: Backend controller, complete the business logically edit Handlerinterceptor    : Processor suspend Handlerexecutionchain: Processor Handleradapter: Processor Adapter Modelandview: Load model data and image information Viewresolver: The image parser flow: The process of the video resolver. 1, the customer request is Dispatcherservlet receive 2, Dispatcherservlet will be asked to map to Handler 3, generate handler and Handlerinterceptor 4, return handlerexecut    Ionchain 5, Dispatcherservlet through Handleradapter execute handler 6, return a Modelandview 7, dispatcherservlet through Viewresolver to parse 8. Returns the view that is populated with the model numbers, which is applied to the client (Internet by draw, invasionRelationship I delete):

It is worth mentioning that the majority of the components are provided by the framework, the developers only need to pass through the configuration of the relationship can be, it is required to hand-write only handler and view.

Environment configuration:

SPRINGMVC Suspend Cutter:

Configure as above:

Java Password:

Suspend cutter and discard device:

(1) Filter: When you have a lot of things, you just want to choose something that meets your requirements. The tool that defines these requirements is the filter.

(2) Interceptor (Interceptor): When a process is in progress, you want to intervene in its progression, or even terminate it, which is what the interceptor does.

With:

(1) Interceptors are based on the reflection mechanism of Java, and filters are based on function callbacks.

(2) The interceptor is not dependent on the servlet container, and the filter relies on the servlet container.

(3) Interceptors can only work on action requests, while filters work on almost all requests.

(4) The interceptor can access the action context, the object in the value stack, and the filter cannot.

(5) in the life cycle of an action, the interceptor can be called multiple times, and the filter can only be called once when the container is initialized.

(6) The interceptor can obtain the individual beans in the IOC container, and the filter does not, it is important to inject a service in the interceptor, you can invoke the business logic.

Excerpt: 53996873

Interceptor work is really useful in the authentication of request authority.

dotnet Programmer's Java Crawl Pit Tour (ii)

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.