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);