IbatisNet tutorials for beginners and ibatisnet beginners

Source: Internet
Author: User

IbatisNet tutorials for beginners and ibatisnet beginners
1. What is IbatisNet:
Many people have heard of Ibatis. Yes, IbatisNet Is A porting version of Ibatis on. net, so they are basically similar. Therefore, IbatisNet is naturally a lightweight ORM framework, so we think of hibnate and Nhibnate again. After learning IbatisNet, I will make a simple comparison with Nhibnate. Strictly speaking, IbatisNet is not a very orthodox ORM solution. Unlike nhib.pdf, it has fully automated data operations, including query, insertion, update, and deletion, and is not closely related to database constraints as it does. IbatisNet provides us with a more flexible, convenient, and controllable way to implement solutions similar to ORM. here we need to write all the SQL statements by ourselves, this method has the following advantages and disadvantages:
1. SQL is allowed to be written in the most natural way. There is no String concatenation, no parameter settings, and no results are obtained. It has no impact on the application code.

2. Direct calling of stored procedures is supported. The business logic is separated from the database, and the program is more portable.

3. IbatisNet supports dynamic SQL to process queries.

The biggest drawback is that we still need to write a large number of SQL statements, but we are glad that we only need to provide these SQL statements and provide them with the required parameters, we do not need to participate in the next step. This is also the core function of iBatis. It dynamically generates an executable SQL statement based on the passed parameter values and provides different values for these SQL parameters. Then, according to the configured Data Access driver, DbParameter is automatically added to DbCommand, SQL statements are automatically executed, and IDataReader is used to return the dataset, and one or more strong data class objects are generated and returned.

2. Is iBATIS the best choice for engineering?

IBATIS is a common data ing tool that establishes a ing relationship between database queries and Object Attributes. If the engineer to be developed is based on the Business Object (including the data dictionary object ), therefore, iBATIS is a good choice. When an application is designed and implemented hierarchically, it is a good choice. In this way, the business layer can be separated from the user interface layer.

In the above circumstances, the Object/RelationalMapping (OR/M) tool is also a good choice, such as NHibernate, but iBATIS is not a ing tool for Object relations, it is only used to help program personnel map to SQL statements OR stored procedures. If there is a ing between entities and database tables, OR/M is a good tool, however, if the ing relationship is the ing between the object and the database view, it is not appropriate to select OR/M. If you can write SQL statements or stored procedures that correspond to data columns and objects in a specified database. IBATIS can be well supported no matter what form of data is stored in the database.

Generally, the following situations are more suitable for selection.OR/M tool:

(1) have full control over the database.

(2) The team does not have a database administrator;

(3) The problem domains outside the Database need to be considered as a table;

 IBATIS is suitable for subordinates:

(1) There is no full control over the database, or you need to be able to use it as the original database after database reconstruction and continue to access it legally

(2) The team has a database administrator;

(3) databases are used to simulate problem domains. The main function of an application is to help users use the database model.

Iii. simple comparison with hibernate:

(1) Hibernate has powerful functions, good database independence, and strong O/R ing capabilities. If you are proficient in Hibernate and encapsulate Hibernate properly, the code for the entire persistence layer of your project will be quite simple, with few code to be written, fast development, and great.

The disadvantage of Hibernate is that it has a low learning threshold and a higher level of proficiency. In addition, how can we design O/R ing and balance the performance and object models, and how to make good use of Hibernate requires your strong experience and capabilities, but Hibernate is now a mainstream O/R Mapping Framework, from the richness of documents, product perfection, both versions are faster than iBATIS.

(2) iBATIS is easy to learn and use. It provides the Automatic Object binding function for database queries and provides good experience in SQL, for projects that do not have such high requirements on object models, it is perfect.

The disadvantage of iBATIS is that the framework is still relatively simple and the functions are still missing. Although the data binding code is simplified, the entire underlying database query needs to be written by itself, and the workload is also large, it is not easy to adapt to quick database modification. When the system is under secondary development and cannot control or modify the database structure, iBATIS is more flexible than Hibernate. System data processing capacity is huge and performance requirements are extremely demanding. This often means that we must use highly optimized SQL statements (or stored procedures) to achieve system performance design indicators. In this case, iBATIS has better controllability and performance.

(3) iBatis can be fine-grained. For example, I have a table with several or dozens of fields. I need to update one of the fields. iBatis is very simple, execute an SQL UPDATE TABLE_A SET column_1 = # column_1 # WHERE id = # id # However, It is troublesome to use Hibernate. By default, hibernate updates all fields. Of course, I remember that hibernate has an option to control only the modified fields, but I am not sure about the negative effects of this function. For example, I need to list part of a table. When using iBatis, the advantage here is that I can read a lot of data FROM the database and save the flow of SELECT ID, NAME FROM TABLE_WITH_A_LOT_OF_COLUMN WHERE... generally, Hibernate Selects all fields. For example, there is a table with eight fields, two of which are relatively large, varchar (255)/text. In the above scenario, why should I select them? If hibernate is used, you cannot set the two unnecessary fields as lazy load, because the entire domain object needs to be loaded at one time. At this time, we can see the benefits of ibatis. If I want to update a record (an object), if hibernate is used, select the object and update it again. This is two SQL statements for the database. IBatis only needs an update SQL statement. Reducing one interaction with the database is very important for performance improvement.


How to use:

I will not write this tutorial. I recommend a series of tutorials for you:

Quick bi-learn IbatisNet (http://www.cnblogs.com/woaixiaozhi/category/499999.html) with beginners. I hope this article on the shoulders of others will help you.


Learning vbnet video tutorials for beginners

Hello, I can understand your mood, because I also learned VB by myself. And passed the second level. It is recommended to read books! In the end, you still need to have ''persistence '', and be sure to stick to it to succeed. I used to have no network in my school. If your network is convenient or you don't understand it, you can ask questions online. Stick to it and you will be able to succeed. In addition, I have a self-taught experience on VB in Baidu space. If you are interested, please take a look! Good luck!

C #-based aspnet video tutorial, suitable for beginners

Go here and check out the courses from entry-level to proficient
Tieba.baidu.com/..t&pn;0

Related Article

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.