Hibernate features:
Hibernate powerful database has nothing to do with good, O / R mapping ability, and if you are very proficient in Hibernate, but also for Hibernate to conduct an appropriate package, then your project will be the entire persistence layer code is quite simple to write code that is required less developed very fast, very cool. One-to-one mapping database fields to the PO and Hibernte be the object of such a mapping received PO are different, the essence of this difference is that PO's are flat, unlike Hibernate mapping PO are the expression of three-dimensional object can inherit polymerization relations and so on, which will directly affect your entire software system design. Hibernate for database structure provides a more complete package, Hibernate's O / R Mapping and implementation of POJO mapping between database tables and SQL automatic generation and implementation. Programmers often need a good definition of the POJO to the database table mapping relations can be provided through the Hibernate persistence layer Ways to complete the operation. Programmers do not even need a master of SQL's, Hibernate / OJB storage in accordance with the development of logic, automatically generate the corresponding SQL and JDBC interface calls to implement. Hibernate is the disadvantage of the study did not lower the threshold, it is necessary to master a higher threshold, but also how the design of O / R mapping, object model in terms of performance and how to weigh the balance between, and how to make good use of Hibernate need your experience and ability are strong do, but Hibernate is now the mainstream of O / R Mapping framework, from the richness of documentation, product integrity, faster version of the development than the iBATIS.
iBATIS characteristics:
iBATIS easy entry, namely, that the study by providing a database query function automatic target binding, and continuation of a very good experience with SQL, for not so high requirements of the project object model is quite perfect. The disadvantage is that iBATIS framework is relatively simple, functional still missing, although simplifying the data binding code, but the entire bottom of the actual database query or write your own workload is also relatively large, but not easy to adapt to rapid database modifications. When the system belong to the secondary development of the database structure can not be controlled and modified, and that the flexibility of iBATIS is more suitable than Hibernate. System data processing capacity of large, extremely demanding performance requirements, which often means that we must pass through highly optimized SQL statements (or stored procedures) designed to achieve the system performance indicators. In this case there will be better iBATIS controllability and performance.
For the actual development of the comparison:
1. iBATIS required handwritten sql statement, but also can generate a part of, Hibernate is basically automatically generated and occasionally write some Hql. Same needs, iBATIS work much larger than Hibernate. Similar, in the case of field changes to the database, Hibernate modified little place, and iBATIS to those who place the sql mapping adaptation.
2. IBatis can be fine-grained optimization
For example, I have a table, this table has a few or dozens of fields, I need to update one of a field, iBatis is very simple to implement a sql UPDATE TABLE_A SET column_1 = # column_1 # WHERE but with Hibernate, then more trouble, the case of default hibernate will update all fields. Of course I remember that hibernate has an option can be controlled to preserve only the modified fields, but I am not sure of the negative effect of this feature.
For example: I need to list some of the contents of a table using iBatis when there are less benefits read a lot of data from the database, saving flow SELECT ID, NAME FROM TABLE_WITH_A_LOT_OF_COLUMN WHERE ... under normal circumstances would all Hibernate fields are selected. For example, have a top table has 8 fields, of which 12 have relatively large field, varchar (255) / text. The scene above me why they have elected them? Use hibernate, you also should not these two do not need the field is set to lazy load, because there are a lot of time required to place the entire domain object is loaded out. This time will be able to show the benefits of iBATIS. If I need to update a record (an object), if you use hibernate, are required to select the object out, then another update. This database is for the two sql. IBatis only a necessary and update the sql it. Reduce the time and the interactive database, for performance improvement are very important.
3. The development of:
Development efficiency, I think the two should be similar. Maintainability, I think iBatis better. IBatis because the sql are saved to a separate file. Hibernate and in some cases may PICC java code sql / hql. Relative Hibernate "O / R" is concerned, iBATIS is a "Sql Mapping" implementation of ORM. IBATIS and the focal point, is to POJO and mapping relations between SQL. In other words, iBATIS will not be for programmers in the run-time implementation of automatic generation of SQL. Specific SQL programmers required to prepare, and then through the mapping configuration file, the SQL required parameters, and return the results of field mapping to a specific POJO. IBATIS provided the use of ORM mechanism, implementation of business logic in terms of personnel, in the face of the pure Java object, this layer with ORM implementation through Hibernate basically identical in terms of, for specific data manipulation, Hibernate automatically generates SQL statements , and iBATIS requires developers to write specific SQL statement. Hibernate relative terms, iBATIS to the workload of SQL development and database portability of concession for the system design provides greater free space.
4. Operating efficiency
Without taking into account cache circumstances, iBatis should be faster than hibernate or a lot of.