Mybatis.net-3 mybatis.net namespace Problems

Source: Internet
Author: User

In the previous ing file,Maps/productmap. xmlThe Start mark of the root element of the configuration element is as follows:

 
<SqlmapNamespace= "Entitymodel"Xmlns= "Http://ibatis.apache.org/mapping"Xmlns: xsi= "Http://www.w3.org/2001/XMLSchema-instance">

What is namespace? Is it a namespace in C?

Actually not. In this namespace and the ing fileStatementsThe ID of the SQL statement configured in.

In large projects, there may be a large number of SQL statements. At this time, it is not easy to create a unique ID for each SQL statement. To solve this problem, you can create a unique namespace for each ing file in mybatis, each SQL statement defined in the ing file is an ID defined in the namespace. As long as we can ensure that each namespace is unique, even if the statement IDs in different ing files are the same, there will be no conflict.

Different from C #, this mechanism of using the namespace to manage statement identifiers is not enabled by default. That is to say, we do not consider the namespace we define by default, but directly use the statement ID.

When the namespace mechanism is enabled depends on the settings of usestatementnamespaces configuration parameters defined in the sqlmap. config configuration file. The default value is false.

 
<Properties><PropertyKey= "Usestatementnamespaces"Value= "False" /></Properties>

The namespace mechanism is enabled only when this parameter is set to true.CodeTo access SQL statements. For example, the original statement needs to be modified to the code shown below.

Ilist <entitymodel. Product>Productlist= Mapper. queryforlist <entitymodel. Product> ("Entitymodel. getallproducts",Null);

 

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.