Ibatis development experience (2) ibatis namespace configuration and left/right connection Query

Source: Internet
Author: User
When I wrote an SQL statement on the dao layer a few days ago, but I couldn't find the Statement on the dao layer. The statement has been configured in the sqlmap file. From the error type, I think it is very likely that the search path is incorrect. Finally, I found that it is the role of the namespace parameter in the configuration file. As we all know, namespaces play a role in preventing name conflicts.

When I wrote an SQL statement on the dao layer a few days ago, but I couldn't find the Statement on the dao layer. The statement has been configured in the sqlmap file. From the error type, I think it is very likely that the search path is incorrect. Finally, I found that it is the role of the namespace parameter in the configuration file. As we all know, namespaces play a role in preventing name conflicts.

When I wrote an SQL statement on the dao layer a few days ago, but I couldn't find the Statement on the dao layer. The statement has been configured in the sqlmap file. From the error type, I think it is very likely that the search path is incorrect. Finally, I found that the namespace parameter in the configuration file plays a role. As we all know, namespaces are used to avoid naming conflicts, in various java classes, packages and namespaces are used to avoid conflicts. Therefore, it is generally enabled, but it does not work if it is not configured in ibatis, therefore, I checked how to configure ibatis. The configuration is as follows:

 
     
  
    
    
    
    
    
 

In the sqlMapConfig tag, there is a settings element, which is used for various configurations of ibatis, Element is used to configure and optimize various options of the SqlMapClient instance. This element itself and the attributes it contains are optional. Therefore, we can use this attribute without adding it.

This element can be used to set some common functions such as namespace, cache configuration, lazy loading, and the maximum number of sessions. It is worth learning about in terms of performance optimization. For more configurations, see the documentation.

Today, we are working on the form. If there are no functions in the form, we need to implement it by ourselves, write the code, and create tables by ourselves, I think it is quite simple, but sometimes I may encounter problems. I should take a good look at the implementation of this form. In the afternoon, I used the form to make a multi-choice check box and created a dictionary table and a relational table, the two forms are modified one by one and read-only. When loading data records, the data cannot be loaded after half a day, and the data is added to the database. Check the SQL statement carefully, some errors are found. When the primary table and the relational table or other table combinations are queried, if there are no records in other tables, the query may fail, I think this is generally a query of left and right connections, and the SQL statement can be queried after modification. the query of left and right connections is generally used when the table requires a Combined Query, but there are no records on one side, or you can use the connection to query records on one side. See the following SQL statement.

select u.*,ui.checkid from fcs_user as u LEFT JOIN fcs_useritem as ui on u.id=ui.userid where id=':{$urlParam("formid")}:'


In this way, no table record on the left or table record on the right will be found.

There is a need to have a foundation to implement various functions or do anything. Even if you give a new thing a basic knowledge that you will apply in the implementation process, therefore, it is very useful to know where the Foundation will be used.

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.