Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Hibernate ibatis understand?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to understand Hibernate ibatis". Friends who are interested might as well take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to understand Hibernate ibatis.

When you need to write your own SQL when using ibatis, because our SQL cannot fully comply with the SQL standard, it is less portable than the SQL generated by Hibernate. However, since we are less likely to change the database, it is not necessary for us to have SQL compliant so that we can migrate to different servers at a minimum cost. On the other hand, although Hibernate can shield the differences between many databases, it is difficult to take advantage of the advanced features of some databases, such as oracle's analysis and statistics function.

Hibernate is not suitable for the system with non-standard database schema, incomplete constraints and a large number of complex queries. At the same time, the learning cost of Hibernate is high, and it is difficult and risky to fully master Hibernate.

Writing your own framework is not necessarily better, stable, powerful and extensible than ibatis's. And it takes a lot of work to develop your own framework.

If you use dotnet and choose a data layer framework, and there are quite a number of complex SQL in the system, or the database design is unreasonable, there are many dirty data, and there are strict requirements for performance and resources, ibatis is a good choice. His shortcomings are not fatal, and there are some solutions. In particular, when we choose ibatis's dataaccess as the dao framework, we can use both Hibernate,ado.net and datamapper (the core component of ibatisnet), which will reduce the risk to *, and the framework of the whole system is reasonable.

In addition, the use of ibatis can unify the coding style, save development costs, we will not waste energy on paging connection pool primary key generation and other places, you can focus on the writing of business components.

To sum up: most of the time, we have to consider comprehensively the issue of developing our own framework and choosing a third-party framework and what kind of framework to choose. The criterion to be considered is, of course, a balance between the current situation of the project and what we want to achieve.

Ibatis just encapsulates the data access layer and does some object-relational mapping for us. But our price is that we have to write xml configuration files, compared to Hibernate, we have to write a lot of SQL.Hibernate to generate entity classes and basic configuration files directly from the database schema through tools, and in most cases we do not need to write SQL, which will greatly improve the efficiency of development. But these also have a lot of limitations, especially the high requirements of the environment (database design, object design, team collaboration, etc.).

The personal feeling that ibatis is meaningful to the project is that it is small, flexible, extensible, encapsulates the data access layer (transaction, cache, exception, log), and provides dao framework support.

With ibatis we can separate code from SQL. As long as SQL can solve problems, ibatis can help us solve problems more easily and make our project less dependent on a framework (because ibatis is non-intrusive). This will greatly reduce the project risk, reduce the time to solve complex problems, and make the maintenance of the project easier.

It will be easy and natural for ibatis to modify, debug, expand and maintain applications. When making changes, we mainly modify the entity objects that represent the model, the SQL in the xml configuration file, and / or the resultmap of the configuration file (which is often not needed). At the same time, SQL and code are separated, so we don't have to look for SQL. Stringbuffer that needs to be modified between the append methods of the code. The SQL in the configuration file facilitates our debugging and review of SQL and future SQL reuse.

The use of some frameworks will generally slow down the development efficiency in the early stage. Because we need to pay the cost of learning, very often, using the framework needs to write a lot of configuration files, and the development speed is slow when you are not familiar with it; at the same time, the use of the framework often increases the amount of system code, such as model1 and model2 model, the development efficiency should still be model1 fast, and the four-tier architecture must be larger than the two-tier code. However, for the middle and later stage of development and maintenance will greatly improve the efficiency.

The use of some more complete development frameworks and code generation tools will greatly improve the development efficiency in the early stage, but it will often slow down the progress in the later stage, and may become a nightmare for future maintenance. For example, torque generates entity classes and their corresponding SQL, which greatly improves the efficiency, but has a heavy burden of modification.

The ideal way of development is to use a simple framework combined with a simple code generation tool. The framework provides the basic services of the system and standardizes the development. On the one hand, the framework provides basic support for a certain aspect of development, such as data access layer, transactions, logs, common classes, exceptions and so on. On the other hand, it also defines the pattern for the development and the basic outline of the system. At the same time, some low-level code is generated through a simple code generation tool. For example, generate entity classes from database schemas through tools. We are free to modify these classes after they are generated.

Hibernate is a very powerful and complete orm framework, but this is both its advantage and its disadvantage. Whether the J2EE system adopts Hibernate3 or not is a problem that needs to be carefully evaluated.

For Hibernate to work well, the design of the database must be good. At the same time, it is acceptable to use SQL,Hibernate3 for complex data operations and support for direct use of SQL is more natural than Hibernate2.

Hibernate is complex, powerful and flexible, so it is not easy to make good use of Hibernate. Of course, the spring framework provides encapsulation of Hibernate, which makes the use of Hibernate a little easier.

It can be said that ibatis works in any system, but it is not necessarily a choice. But ibatis provides ideas that we should consider carefully.

At this point, I believe you have a deeper understanding of "how to understand Hibernate ibatis". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report