Companies are currently used SQL processing business logic, is writing a long SQL statements on dao layer, basic is not written in the Java business logic, but that the database server pressure, low processing performance, but also more complex SQL tuning up, now want to use Java to handle the business logic, but across the table more cases associated 7, 8 table above, business code will be quite complex, what is generally good practice? Is there any standard practice?
CodePudding user response:
Mainstream is a Java write business, some small companies also use SQL to write business now
CodePudding user response:
I can feel to SQL to SQL, so that your business logic is clear and simple,
CodePudding user response:
More inclined to Java to handle the business logic
CodePudding user response:
Business logic is generally Java side out of the SQL is mainly to manage your data storage
CodePudding user response:
refer to the second floor weixin_40290083 response: I think could to SQL to SQL, so that your business logic is clear and simple, The bottleneck of most systems are database, business logic and clear? You just transfer the business logic to SQL Application layer can be easily extended, your database is not easy CodePudding user response:
It's not a standard not standard We assume no business logic, requires the SQL table associated with as little as can use more, inquire on the list with only, other times it is a single table query Only assume the position of add and delete database, application layer processing business logic, while SQL sometimes makes it simple code, but the abuse of SQL can cause more serious problems Specific what to do, you can use the jpa, or mybatis reverse engineering, so that you can simple code to query data, but this does not prohibit you from writing the complex SQL You have to regulate CodePudding user response:
Business logic to Java ah, the relevant operations in SQL database CodePudding user response:
A poke long SQL horror, I practice is encapsulated into a business object, a table and provide relevant interface call for other modules. CodePudding user response:
I remember a bosses said before: the database just as tools for storing data, that's all, CodePudding user response:
In front of the brothers said, Java write 1, big companies formal, business, with a single table query, such as: the correlation between 7 and 8 tables, you finally settled or only to 1-200 ID used to check the data, then find the ID used IN single table to check, Performance associated with 7-8 table must be fast. We have a project is tested at the provincial level, the customer table about 20 million, and tens of millions of other data tables, data table about 5 billion lines, some of the data table has 40 billion rows. Check a few minutes to get the results, If a single table with IN 3 seconds. So this case, the business should be handled in Java, SQL is a single table, as far as possible let query condition is the primary key, or index. 2, if the project is not normal for fast, try to end the contract, just think how to play how to play, can't solve the problem of performance, the contract is the most important, the company leadership think you how to play how to play. 3, when the company want to optimize, we'll see. Chinese software do bad, is related to the environment, so a person just do your own thing, we can't change the environment. (so what do you want to use the standard model, interface, paradigm, it takes time, unless the company has accumulated) 4, the practice of our company: First dao: make each table operation is a service/micro/or only can jar package, specification for each table operations, but the API must be complete, big workload is very large (code generation). Then biz: the service in the business layer, such as: WeChat interface services] [unified order business, the business layer of the service transaction can be used to control, also can use hard-coded if control and so on, the business layer is called the dao layer each table to the basic service implementation, is according to the business combination to the operation of the table. Finally show layer, the action and so on, such as JSP calls business layer is mainly services, part also calls the dao layer basic services. To the final completion. CodePudding user response:
Java processing is better, can clip figure logic points, the pressure will be smaller, then the database and SQL coupling also can reduce a lot of, CodePudding user response:
If the company requirement, then according to the requirements of, not standard can you change? If can change, of course, is in accordance with the MVC pattern to the best, unless you can everything stored procedures, so that even the SQL in Java code without having to deal with, deal directly with the stored procedure, Normal mode should be: Java to handle business logic and SQL processing related to data only add and delete operation, CodePudding user response:
Look at the situation, but I think if written in the Java to logic, SQL can be better reuse, The same SQL returns the same result, may to the place where different call need to display the results of the different, so that in Java to processing logic is better, CodePudding user response:
Database is used to store more data, business handling this mainly to the Java code to handle, seen a job 78, id card in the middle the asterisk hidden in database processing, the use Java code to handle more convenient and more quickly, such as this, the Java to handle faster why use SQL? CodePudding user response:
Java to handle the business logic CodePudding user response:
Unless leadership tool rest on the neck, or Java process, see a tuo SQL are headache, optimization to you doubt life CodePudding user response:
Business logic code, the database is responsible for a small group of data storage logic, CodePudding user response:
The choice to choose according to actual situation, choose factor are many, there is no absolute good written in Java, there is no absolute good written in SQL, only the most appropriate, only suitable is the best, make technology of what, also don't be so extreme must use the same set of solutions can't play all over the world, different companies the same decision environment may produce different results, more is to adjust measures to local conditions, the current actual situation according to their own company Simple a few example Related to your company type, for example, Internet companies and traditional enterprise must be different, the traditional business enterprise business system after years of development is very complex and platform are older, not you usually add and delete that simple, basically all had formed the ecological reconstruction cost is very high, and there is no must reconstruct the necessity, probably most of the business are not in Java are written in the book of the stored procedure, the business logic written in SQL stored procedures must be the most appropriate choice, and convenient operations, if it is Internet companies, especially the new start-up business is very simple, basically use also is the latest technology, the traditional enterprise business scenarios of processing is much simpler, more than a table also is less, basically will be written in Java, Also related to the platform, for example, technology develops so fast, now believe that only a few years the company platform, old platform for business a lot written in SQL, the more the new platform written in Java, the more the old platform could not one size fits all to a new platform, Also related to the project, for example, some platform suitable for if you are old platform project optimization is to use stored procedures with the original SQL, enough to believe that the company won't let you spend a big cost to change to Java, unless stuffed with a let you waste your cost of doing this, the new platform usually doing in the new business development is written in the Java more commonly, also have migrated from the old system, new developers generally do not understand the business will be carried out in compromise, And related to application scenarios, for example, some scenes for written in Java, some scenes for write in SQL, such as the mass or the same library is very frequent operating data from a table into another table, this kind of situation will not need to query the data to the application layer from the application layer into database, write directly in the SQL is the best there is no network overhead, if they are across databases, speaking, reading and writing, must be written in the Java process is one of the best And with the company, the customer management policy, related network security, maybe many times company policy determines your technology selection Anyway, we all try to innovate new platform began to transform the old business written in Java, there are also failures into cost far more than expected benefit is quite small, the end result is your department fell out of word of mouth, and you know,,, no optimization in complex business processing to write SQL stored procedures good reading and writing data repeatedly cause performance bottleneck, the system response is slow, failure problem caused by too many customer complaints, the end result is likely to customer review, criticism, and so on, also will have you know,, And experience is not only related to the development, the response of the system hardware and software architecture, with the first system deployment of hardware equipment performance, deployment, deployment container, link, network, etc have relations Finally the sentence according to actual condition adjust measures to local conditions, the current environment, which suits to choose which business scenarios, and technology final purpose is to serve people, not people been strangled with the technology, CodePudding user response:
More inclined to Java to handle the business logic CodePudding user response:
Complex business logic suggests in Java code to handle, SQL processing, if the database upgrade or migration, that are likely to be written again CodePudding user response:
Java to handle the business logic is normal, normal handling, through the Java process business logic can do load balancing, performance tuning, such as distributed with high system capacity, the method of theory and mature, the tool is complete, In the project to solve specific, see you what is the problem to be solved, if the performance has reached or close to requirements, only because of the complex, SQL suggest or overcome the technical difficulties; If higher performance requirements, then take time to refactor, The complexity of the refactoring is higher, should have prepared, CodePudding user response:
SQL to write business logic is not necessarily good Java, late customer demand to change the SQL statement is very troublesome, and the business logic code in Java is relatively good processing, besides the server-side business logic processing capacity is not slower than the database, CodePudding user response:
SQL problems can't screening, brother crynullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull