Hibernate framework with the advantages of enterprise
Original Address: http://java.ccidnet.com/art/3539/20070601/1098749_1.html
1, Hibernate JDBC is the object of the lightweight package, it is an independent object persistence layer framework, and App Server, EJB and no necessary link. Hibernate can be used in any JDBC can be used, for example, a Java application database access code, DAO interface implementation class, and even inside the BMP can access the database code. In this sense, Hibernate and is not an area of EB, nor the relationship between the existence of either-or.
Second, Hibernate and JDBC is a closely related to the framework, Hibernate compatibility and JDBC driver, and databases have a certain relationship, and the use of its Java procedures, and App Server does not have any relationship or compatibility problems exist .
3, Hibernate and can not be used to directly comparing Entity Bean, the only item on the J2EE framework can be compared. And even on the overall framework of the software, Hibernate as JDBC is the alternative to, rather than a replacement for Entity Bean there, let me out once I have set out the framework structure of the n:
Traditional Architecture:
1) Session Bean <-> Entity Bean <-> DB
In order to address the obstacles to performance alternative framework:
2) Session Bean <-> DAO <-> JDBC <-> DB
Hibernate use of the above structure to improve the efficiency of the development framework:
3) Session Bean <-> DAO <-> Hibernate <-> DB
On the above three structure analysis:
1, memory consumption
2 using JDBC framework is undoubtedly the most in memory, Hibernate framework three times, the structure of an EB worst.
2, operating efficiency
If JDBC code optimization is written, then JDBC framework maximum operating efficiency, but the actual project, this is almost impossible, this requires programmers JDBC very proficient using Batch statements, the adjustment PreapredStatement Batch Size and parameters such as Fetch Size , and, if necessary, under the circumstances, the result of a cache, and so on. Programmers and under normal circumstances is impossible this point. Hibernate framework therefore show the fastest operating efficiency. EB efficiency of the structure will be far worse.
3, the efficiency of development
In JBuilder have the support of the project as well as a simple, EB framework for the development of the highest efficiency, JDBC times, Hibernate worst. However, in large projects, in particular the persistence layer relationship mapping complex circumstances, the astonishing Hibernate high efficiency, JDBC times, and EB structure is likely to fail.
4, distributed, security checks, clustering, load balancing support
As SB as a Facade, three structure no difference.
4, EB and Hibernate learning difficulty where?
Where is the difficulty of EB? Not complicated XML configuration files, but a little careless use of EB, there is a serious obstacle to the performance. So you need to study hard in a lot of EJB design patterns to avoid performance problems, and need to learn App Server EB EB configuration to optimize the operating efficiency. EB do the development work, most programmers have been put on the performance of the EB on the issue, but did not concern itself more energy on the main input energy to consider the subject of persistent layer of the design.
Hibernate Difficulties? Hibernate is not the complex itself, in fact very simple Hibernate, it is difficult in the Hibernate too flexible.
When you use to achieve lasting EB layer, you will find that EB is too clumsy, awkward to what can you do not have a choice, so you simply do not have to spend energy to the design options to balance the merits or demerits of the programme, for their brains to consider choosing which option, because only the only place in the programme before you, you can only do this, not a choice.
Hibernate Rather, it is too flexible, the same question, you can at least design several options to resolve the 10, special Fannan, whether to use this or use that? These programmes What is the difference between in the end? Their operating principle of what's the difference? Which is better operation efficiency? Just primary key generation, there are 78 kinds of options for your choice, not you feel embarrassed? Set attributes can be set, the List can be used, but also can be used Bag, which highly efficient in the end, do not you feel embarrassed? Enquiries can be used iterator, can be used list, which is good, What is the difference? Do not you feel embarrassed? You can composite primary key hbm inside directly in the configuration can be customized CustomerType, which some compare? Do not you feel embarrassed? For a table, you can choose a single map an object, can be mapped into his son object can also be mapped into two 1:1 object, under what circumstances by which the programme is good, you feel no embarrassment?
This list has been provided can go on until you do not want to look at it so far. When you have before them countless dazzling programme, you will find happiness? Or sad? If you are a programmer responsible, then you will carefully study the difference between each programme, the efficiency of each programme, the application of the programme each occasion, you will feel that you do not have a get out Stubbs. If it is used EB, your first on the second kind of decision has been made, it is not a choice, for example, attribute sets, you can only use Collection, if Hibernate, you will Bag, Set List, and do not hesitate back and forth between summary and even unclear, have no means of written procedures.
Tags: enterprise, framework, hibernate, java framework






