In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail the advantages and disadvantages of JPA and Hibernate. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Java Persistence API
Since EJB technology can be applied, there have been doubts about its availability in practical applications. In my opinion, the two most important reasons for this phenomenon are complexity and resource intensity. As a result, frameworks that are simpler than EJB and have less resource space (such as Spring and Hibernate) emerge and catch on more quickly. To illustrate this point, we noticed a major shift in the direction of the EJB 3.0 specification from before. As part of JSR 220, the specification provides features such as Plain Old Java Object (POJO) support, Dependency Injection (dependency injection), and annotations. Now a whole new set of API:Java Persistence API (JPA) has been introduced to allow developers to manage relational data in Java EE (and even SE) applications. In addition, Sun claims that Java Persistence API represents some ideas in Hibernate, TopLink (both of which will be discussed later), JDO, and the EJB framework.
Currently, the GlassFish project provides a reference for implementing JPA, and JPA is part of the TopLink Essential in the GlassFish application server. You can find the JPA reference implementation on the GlassFish community page. Don't confuse TopLink Essentials with TopLink, which is now a relational mapping tool owned by Oracle Corporation. I will discuss the TopLink framework later in this article.
Let's discuss some application scenarios where you should consider applying JPA as a persistence framework.
When to consider JPA as a persistence framework
You choose to apply standards-based frameworks with "good" functionality from popular frameworks such as Hibernate, TopLink, and EJB.
You need a lightweight persistence framework and you don't need the services provided by EJB's containers.
You need a persistence framework that can be used in standard or Enterprise Java applications.
When to consider the alternative of JPA
The version of Java you use determines whether JPA can actually be applied. JPA is part of the EJB 3.0 specification, which is part of the Java EE 5 version. If you do not update to Java EE 5, you cannot use JPA.
Your application needs services that JPA cannot provide, such as those provided by EJB containers, in which case you are more dependent on EJB.
Before concluding the discussion of this framework, let's list some of the advantages and disadvantages of using JPA as a persistence framework.
What are the advantages of JPA?
JPA is standards-based. More and more providers are looking forward to providing JPA implementation in the near future.
It provides the same functions as in Hibernate and TopLink.
It can be used with Java SE and Java EE applications, with or without the EJB container.
What are the disadvantages of JPA?
Because it is very new, the JPA specification may need to undergo significant developments before it becomes stable.
JPA is a specification, not a product. You need a provider to provide an implementation to gain the benefits of these standards-based API.
Hibernate
Hibernate is an object persistence framework that simplifies object-relational mapping between Java applications and underlying relational databases. This is done by providing transparent persistence of POJO, acting as a "mediation" layer to provide automatic persistence, and loading objects into database tables from the Java application. With Hibernate, saving object state to and loading object state from the database is as easy as calling methods in Java objects. You don't need to manage the underlying data operations from your application code; the Hibernate framework does all the intermediate steps for you.
Let's discuss some application scenarios where you will consider using Hibernate as a persistence framework, as well as those where you will look for alternatives.
When to use Hibernate as the persistence framework
You are looking for a simple persistence framework that is easy to learn and use. Before you can actually start persisting your Java objects to the target database, you only need to know a few mapping configuration files.
You are looking for a very generic and flexible persistence framework. The use of Hibernate is very flexible: it can be used with or without an application server, with or without a relational database system.
You do not want to pay for acquisition and maintenance. Hibernate is open source and free.
The Hibernate framework is well worth using because it is very simple and flexible, as well as powerful. However, you may want to consider applying other frameworks in some of the following application scenarios.
When to consider alternative frameworks for Hibernate
You don't want another framework yet. Although simple, the Hibernate framework still has its own learning curve, maintenance / update cycle, and so on.
You need services provided by the container, such as those provided by EJB, and in those cases your choice is limited to EJB.
If you are using or planning to use Hibernate as your persistence framework, here are some of its advantages and disadvantages.
What are the advantages of Hibernate?
Hibernate is easy to learn and use. As I mentioned above, you only need to know a few simple, self-describing configuration files before you can use it.
It's very flexible. You can use Hibernate in any application architecture that requires persistent services. You can use it in Standard Java applications, Enterprise Java applications through Servlet and / or Enterprise Java Bean. It also integrates well with the Spring framework.
It scales up well because it is designed to work from the bottom to the cluster environment. The performance of the * version of Hibernate has also been enhanced through Lazy Initialization-like techniques and optimizing Java reflection through the CGLIB runtime bytecode generation library.
What are the disadvantages of Hibernate?
Hibernate is another framework with its own application and maintenance cycle.
Despite active community support, sometimes the lack of a provider focused on this product makes it unconvincing to promote the application of this framework.
This is the end of the article on "what are the advantages and disadvantages of JPA and Hibernate". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 246
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.