1. Key Knowledge Review
The purchase and Sale contract view, uses the similar hibernate way, all by the object Association way.
(1) Po in order to take advantage of mybatis performance, at the time of creation, there is no association object association, but the object key field, that is, the foreign key, using this common attribute, to record the value, the relationship between table data exists, but the object association relationship does not exist. The code becomes simple. As soon as the goods are added, the main table ID can be taken from the main object.
(2) VO takes data when it is convenient to associate objects. In the list of circular cargo information, to query the current goods under the attachment, if the above method, can only be queried again. However, we can get the collection of attachments directly under the current goods by the object-related method, and all the attachments of SQL are queried.
Po/vo are all Pojo objects. Based on the current environment of the business.
Inquiries about the number of goods and the number of attachments (multiple goods under one contract, multiple attachments per shipment)
Method 1: The code can check the number of goods and the number of attachments by the contract number; it needs to issue multiple SQL queries again.
Method 2: Use SQL statement support directly, it can put a result set as a field value, so that the SQL returned result set must be a column. At the same time in this sub-query, its conditions can be spliced dynamic conditions.
contract_id=t.contract_id T is a nickname for the general table. This introduces a dynamic condition. An analogy is implemented to query the number of attachments.
Method 1 and Method 2 are not efficient. For Method 1, you re-emit the SQL subquery. Low efficiency. Many subqueries are nested for method 2,sql, but it is the database level (that is, running on a powerful server), and the database under the powerful server architecture can handle complex nested statements.
(Why is it inefficient to re-emit SQL subqueries more efficiently than nesting many subqueries?) Because every time you re-issue SQL, you need to reconnect the database connection pool, open the transaction, then disconnect the transaction after the query is finished, close the link to the database connection pool, and then proceed to the next SQL query, so this wasted a lot of time and resources. )
Method 3 efficiency is higher than Method 1 and Method 2, what is Method 3?
Method 3: Redundancy + sub-calculation "highlights"
The number of goods and the number of attachments is set up in the table, the current contract, the number of goods +1 when the goods are added. Removal of goods, number of goods-1; When the annex is added, the annex number of the current contract is +1, the annex is deleted, the number of attachments-1; When the goods are deleted, the total number of attachments below them is subtracted from the number of contract attachments. The code is more complicated to consider, but it is computationally efficient because it is scattered everywhere. When querying, there is no need for dynamic computation, which is highly efficient.
Permissions "Highlights"
Role user rights, which is used by most systems.
Fine-grained permission control, which controls access to data. The permission schema solves the application of our actual project. (e.g. financial)
Reprint Please specify Source: http://blog.csdn.net/acmman/article/details/48678547
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"Springmvc+mybatis project" Jie Xin Business-23. Key Knowledge Review