< >hibernate's advantages and disadvantages (limitations)

Source: Internet
Author: User

This text link:http://hi.baidu.com/ko22223/item/dd9f6900015adc036d904877

Hibernate is a lightweight object encapsulation of JDBC, which is a stand-alone object persistence layer framework, and the app Server, and EJB have no inevitable connection. Hibernate can be used wherever JDBC can be used, such as the database access code for Java applications, the implementation class for DAO interfaces, or even the code that accesses the database in BMP. In this sense, hibernate and EB are not a category of things, and there is no either-or relationship.

Hibernate is a framework that is closely related to JDBC, so hibernate compatibility and JDBC driver have a certain relationship with the database, but the Java program that uses it has nothing to do with the app server and there is no compatibility issue.

Hibernate cannot be used to directly compare with the entity bean, only in the framework of the entire EE project. And even in the overall framework of software, Hibernate appears as a substitute for JDBC, not as a substitute for an entity bean, and let me list the frame structure that I have listed n times:

The traditional architecture:
1) Session bean <-> Entity Bean <-> DB
To address the alternative architecture of performance barriers:
2) Session Bean <-> DAO <-> JDBC <-> DB
A schema that uses Hibernate to improve the development efficiency of the above architecture:
3) Session Bean <-> DAO <-> Hibernate <-> DB

The above 3 architectures are analyzed:
1, memory consumption: The use of JDBC Architecture 2 is undoubtedly the most memory-saving, Hibernate architecture 3 times, EB Architecture 1 the worst.

2, operating efficiency: If JDBC code write is very optimized, then the JDBC schema is the most efficient, but the actual project, this is almost impossible, which requires the programmer is very proficient in JDBC, using batch statements, adjust Preapredstatement batch Parameters such as size and fetch size, as well as the use of result set cache if necessary, and so on. In general, programmers can't do this. The Hibernate architecture therefore shows the fastest running efficiency. EB's architecture is far less efficient.

3, development efficiency: with JBuilder support and simple projects, EB architecture development efficiency is highest, JDBC second, hibernate is the worst. However, in large projects, especially when the persistent layer relationship mapping is complex, hibernate is surprisingly efficient, JDBC is second, and the EB architecture is likely to fail.

4. Distributed, security check, cluster, load balancing support
Since there is no difference in the facade,3 architecture of SB.

Iv. What is the difficulty of studying EB and hibernate?

Where is the difficulty of EB? Not on complex XML configuration files, but in the slightest careless use of EB, there are serious performance hurdles. So hard when you need to learn a lot of EJB design patterns to avoid performance problems, you need to learn the configuration of App server and EB to optimize the operation efficiency of EB. To do EB development work, most of the programmer's energy is put on the performance of EB, but there is no more attention to their own focus on the main focus on the design of the persistence layer of the object.

Where is hibernate difficult? Not in Hibernate itself complex, in fact hibernate is very simple, difficult in hibernate too flexible.

When you use EB to achieve the persistence layer, you will find that EB is too clumsy, clumsy to you have no choice at all, so you do not have to spend energy to design programs, to balance the quality of the plan, to the cost of thinking about choosing which option, because only the only solution in front of you, you can only do so, No choice.

Hibernate on the contrary, it is too flexible, the same problem, you can at least design more than 10 kinds of solutions to solve, so especially puzzled, on earth with this, or with that? What is the difference between these programs? How do they differ in how they operate? Running efficiency which is better? Just the primary key generation, there are seven or eight kinds of options for you to choose, you are embarrassed? Set properties can be set, can use list, can also use bag, in the end which high efficiency, you embarrassed not embarrassed? Query can be used iterator, can use list, which is good, what is the difference? Are you embarrassed? Composite PRIMARY key You can configure it directly in HBM, or you can customize the CustomerType, which is better? Are you embarrassed? For a table, you can choose a single mapping of an object, you can also map to a parent-child object, you can also map to two 1:1 of the object, under what circumstances in which scenario is better, you are embarrassed?

This list can be listed all the time until you don't want to see it anymore. When you have a myriad of dazzling solutions in front of you, you will feel happy? Or is it sad? If you are a responsible programmer, then you will be careful to study the difference between each scheme, the efficiency of each scheme, the application of each scenario, you will feel that you have been caught in the pull out. If you are using EB, you have made a decision in the first second, there is no choice, such as set properties, you can only use collection, if it is hibernate, you will be in bag,list and set back and forth hesitant, even if it is unclear, the program is not able to write.

Hibernate as a persistent framework has a long history of "according to it Time", in the year when the ORM framework was chaotic, Hibernate did a solo show, played a mainstay role, resulting in the present struts+spring+ Hibernate's perfect three-layer development model is formed.

Unfortunately, with the introduction of EJB3 persisence technology from the EJB altar to walk down the thousands of households, the Java language is the most introduced database access, become the standard ORM framework.
Ironically, EJB3 's main participant was the author of hibernate ...

So, I think, hibernate can be optimistic, but the entity class is more worthy of attention, by the way, with the increasing promotion of persisence, Hibernate3.2 has officially obtained JPA certification, which means that hibernate is already an implementation of the Persisence standard. I hope you can see the future and not indulge in hibernate. Persisence is the most promising ORM standard, Hibernateentitymanager is just a concrete implementation of it.

PS: The above content is from http://hi.baidu.com/ko22223/item/dd9f6900015adc036d904877, I have not made changes.

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.