What [turn] use Hibernate benefits are?

A, Hibernate is a lightweight JDBC object package, it is an independent object persistence framework, and App Server, EJB and there is no necessary link. Hibernate can be used in any occasion using JDBC, such as database access code Java applications, DAO interface implementation class, or even a code to access the database BMP inside. In this sense, Hibernate and EB is not a category of things, there is no either-or relationship.

Two, Hibernate is a framework and is closely associated JDBC, Hibernate is compatibility and JDBC drivers, and the database have a certain relationship, but the Java program and use it, and App Server does not have any relationship, there is no compatibility issues .

Three, Hibernate and Entity Bean can not be used to make a direct comparison, only on the entire J2EE framework project to compare. And even if the software is on the point of view the overall framework, Hibernate also appeared as a substitute for JDBC, rather than a replacement for Entity Bean arise, let me once again my column frame structure n times already listed:

traditional architecture :
1) the Session Bean <-> the Entity Bean <-> DB
to address alternative architectures performance barriers:
2) the Session Bean <-> DAO <-> JDBC <-> DB
using Hibernate to improve development efficiency above schema architecture:
3) Session Bean <-> DAO <-> Hibernate <-> DB

on the top three architectures to analyze:
1, memory consumption: using JDBC framework 2 is undoubtedly the most provincial of memory, Hibernate 3, followed by architecture, EB's 1 worst architecture.

2, operating efficiency: if the JDBC code written in a very optimized, then the maximum operating efficiency JDBC architecture, but the actual project, which is almost impossible, which requires very proficient programmer JDBC, use Batch statements Batch Size PreapredStatement of adjustment Fetch Size and other parameters, and use the result set in the cache and the like if necessary. Under normal circumstances the programmer can not do this. Therefore Hibernate framework to show the fastest operating efficiency. EB architectural efficiency will be far worse.

3, development efficiency: With the support of JBuilder and have simple projects, EB to develop the most efficient architecture, JDBC followed, Hibernate worst. But in large projects, in particular the persistent under-relational mapping layer very complicated situation, high efficiency amazing Hibernate, JDBC, followed by EB architecture and is likely to fail.

4, distributed, security check , clustering, load balancing support
because of SB as a Facade, 3 a framework of the no difference.

Four, EB and Hibernate where the difficulty in learning?

Where is the difficulty in EB? Not on complex XML configuration file, but rather use a slightly EB mistake, it is a serious obstacle to performance. So you need to learn a lot of difficulty in EJB design patterns to avoid performance issues, you need to learn and EB App Server configuration to optimize the operating efficiency of EB. EB do development work, most programmers effort have been put on the performance of the EB issues, but no more energy to focus on the design itself primarily devote their energies to consider the object persistence layer up.

Hibernate Difficulties? Hibernate itself is not complicated, in fact, Hibernate is very simple, difficult in Hibernate too flexible.

When you use EB to achieve persistence layer, you will find that EB is too clumsy, awkward to you there was not any room for choice, so you simply do not need to spend energy to design, to balance good and bad programs, brainer to consider which option, because there is only one program in front of you, you can only do that, did not have a choice.

Hibernate Instead, it is too flexible, the same problem, you can design at least a dozen programs to address, it is particularly the screenwriters, what with this, that or use it? In the end what is the difference between these programs? Their operating principle What is the difference? Operating efficiency which is better? Just primary key generation, Seven or eight kinds of programs to choose from, you feel uncomfortable not difficult? Collection of attributes you can use Set, you can use List, you can also use Bag, which in the end high efficiency, do not embarrass you feel uncomfortable? Queries can be used iterator, can list, which is good, what is the difference? You feel uncomfortable not difficult? Composite primary key that you can configure directly in hbm inside, you can also customize CustomerType, which is somewhat better? You feel uncomfortable not difficult? For a table, you can select a single map objects can be mapped into a parent-child object can also be mapped into two 1: 1 objects, and under what circumstances with which program is better, you feel uncomfortable not difficult?

This list can go on has been set out, until you do not want to look down so far. When you stood in front of countless dazzling program, you will find happiness? Or sad it? If you are a responsible programmer, then you will carefully study the difference of each option, the efficiency of each option, the application of occasions each scenario, you will feel that you have been caught inside pull it out. If you are using EB, the first seconds you will have made a decision, there is no choice, for example, a set of attributes, you can only use Collection, if it is Hibernate, you will be between Bag, List, and Set forth without hesitation decisions, even confused, then there is no way to write programs.

Turn: https://bbs.csdn.net/topics/370049844 .

Guess you like

Origin www.cnblogs.com/day1day1up/p/11126508.html