In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "what are the five core interfaces in Hibernate". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn what are the five core interfaces in Hibernate.
1.Configuration core interface
In the Hibernate application, the object-relation mapping file is specified through the instance of Configuration or the properties of Hibernate are dynamically configured through Configuration, and then the corresponding SessionFactory instance is created through Configuration. So the main role of Configuration is to configure and start Hibernate.
2.SessionFactory core interface
In Hibernate applications, a SessionFactory corresponds to a data source, which is a heavyweight object (Note: multiple instances cannot be generated at will. For a general single database application, only one SessionFactory is sufficient, of course, if there are multiple databases, it is still necessary to generate a corresponding SessionFactory for each database.) it is thread-safe, and the same instance can be shared by multiple threads in the application. At the same time, SessionFactory stores a large number of predefined SQL statements and mapping metadata, which requires a large cache and a certain amount of CPU time to calculate and generate.
Note: through the definition of the Mapping file, many SQL statements have been identified and only need to be generated dynamically once to improve the efficiency of persistence.
3.Session core interface
Session interface is the most widely used interface in Hibernate applications. It is a persistence manager that provides add, update, delete, load and query objects. Session is not thread-safe, so avoid sharing the same Session instance with multiple threads. Session is a lightweight object, and its creation and destruction do not require much resources, which means that Session objects can be created and destroyed frequently in applications.
Session has a cache, called Hibernate's first-level cache, which stores persistent objects loaded by the current unit of work. Each Session has its own cache, and the objects in the cache can only be accessed by the current unit of work.
Note: Session instances are available from SessionFactory.
4.Transaction core interface
Transaction is the database transaction interface of Hibernate, which encapsulates the underlying moral transaction interface. The underlying transaction interface includes:
JDBC API
JTA (Java Transaction API)
CORBA (Common Object Requet Broker Architecture) API
Hibernate applications can declare transaction boundaries through a consistent Transaction interface, which helps applications to be portable in different environments or containers. The specific transaction implementation is specified in Hibernate.properties.
5.Query and Criteria core interface
These two are the query interfaces of Hibernate, which are used to query the database for objects and to control the process of executing the query. The Query instance wraps a HQL (Hibernate Query Language) to query. Criteria interface completely encapsulates query statements based on string form, which is more object-oriented than Query, and Criteria is better at executing dynamic queries.
The above is all the content of the article "what are the five core interfaces in Hibernate?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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: 0
*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.