开发者

Hibernate advantage? [closed]

开发者 https://www.devze.com 2023-01-24 11:24 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago.

Any one can gi开发者_运维问答ve me the gist of the main advantage of using Hibernate?


Hibernate lets you develop a maintainable data access layer with relative ease.

Hibernate is built on top of JDBC, so obviously it cannot do anything that plain JDBC cannot do. Hibernate is a large codebase; if you are building your own data access layer using plain JDBC, you will have lot more code to write to match its features. In simple reporting applications, it is relatively easy to code up the data access layer features you need; but as the application gets more complicated, the amount of code one has to write increases. Let me give you few examples that are non-trivial to implement by hand, but comes out of the box with Hibernate:

  1. Ensuring a global lock acquisition ordering
  2. Determining which fields of an object has changed and tailoring the query appropriately (may not be a good idea always)
  3. Flexibility to switch between various fetch strategies ("here I want the User and Address loaded together, but here I just want User only") in different usecases

As I hinted before, implementing these by hand is not impossible - afterall, Hibernate does it. But they take significant investment in time. In many (most?) applications, concentrating on the complexities of the business logic would be a better investment of developer time.

Please see my comment in another thread regarding Hibernate performance.


I've found it useful if you need your application to work with several different databases. Hibernate will make it much easier to swap out a MySql DB with an Oracle one for example.


Easier development, but only for simple applications.

See the answers in How can I design a Java web application without an ORM and without embedded SQL for more.


Not having to write your own DAL.

There might be a steep learning curve initially but once you get the gist of it, it does lead to quicker development.


It's is ORM Framework (Object relationship maping ) !


ORMs (like Hibernate) make it possible to use POJOs / POCOs that have solid, reliable database backing with a minimum of fuss. (Note: quantity of fuss is not guaranteed to be zero, but usually less than with other solutions. YMMV.)


Hibernate increases the productivity and maintainability of the project.
This is may help
http://mudassirshahzad.com/why-hibernate-should-be-chosen-for-projects-advantages-of-hibernate/

0

精彩评论

暂无评论...
验证码 换一张
取 消