Java Web Project Optimization

Source: Internet
Author: User

Personal Summary of the Java Web considerations 1, prohibit in the loop, the operation of the database operations. The reason is that the operational database is time-consuming to open and shut down memory For example: try to avoid the following actions in the programFor (Object o:entitys) { Save (o); update (o); Delete (o); //
}
2, in the program appears HQL or SQL statement, as far as possible to filter the data more than the conditions first place         3, at the beginning of the design data, use frequent data as far as possible redundant fields. Avoid connecting tables when querying, consuming data query time. For example: the relationship between people and departments; a person has multiple departments, a department has more than one person, and everyone has a default department          
4. In the Java program Hql/sql, try not to call system functions in the where bar or select. The following conditions:     
<strong>  StringBuilder sbud = new StringBuilder ("SELECT DISTINCT tps.project_id  ID from  t_project_ Stage TPs ");               Sbud.append ("INNER join t_stage ts on ts.id = tps.stage_id  where  ");               Sbud.append ("  tps.last_modified is not null and tps.last_modified-1<to_date ('%2$s ', ' Yyyy-mm-dd ')");//               Sbud.append ("and Tps.last_modified <  to_date ('%3$s ', ' yyyy-mm-dd ') +1 and tps.overdue=0  GROUP by TPS.PROJECT_ID has MAX (ts.order_no) =%1$s) tt2 on Tt.id =tt2.id ");               Sbud.append ("and to_date ('%3$s ', ' yyyy-mm-dd ')  < <span style=" color: #ff0000; " >ADD_MONTHS</span> (tps.last_modified, 2) +1 and tps.overdue=0 and  ts.order_no=%1$s) tt2 on Tt.id =tt2.id " );               Builder.append (String.Format (sbud.tostring (), witchstage,firstday,firstday));</strong>


Redundant fields are recommended if the amount of data is large. 5, if more than one place in the program using HQL query or local SQL query more than one table, you can use SQL stored procedures, SQL view, unified interface, to increase the reusability of code. Note: you can create an entity class for a view


The above views: purely personal views, if there are errors, please the Great God guidance!














1

Java Web Project Optimization

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.