Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is Hibernate Configuration?

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is Hibernate Configuration". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is Hibernate Configuration".

Hibernate Configuration

Hibernate Configuration is the entrance to hibernate. When creating an instance of Configuration, hibernate will look for the hibernate.properties file in classpath. If the file exists, it will load the contents of the file into an instance of Properties, GLOBAL_PROPERTIES. If it does not exist, it will print the message: hibernate.properties not found and then add all the system environment variables (System.getProperties ()) to the GLOBAL_PROPERTIES. If the hibernate.properties file exists, the system will also verify the validity of the file configuration, and the system will print a warning message for some configuration parameters that are no longer supported.

(1) function-to configure Hibernate

The purpose of the ◆ Configuration interface is to configure Hibernate and start it. During the startup of Hibernate, an instance of the Configuration class first locates the mapping document, reads these configurations, and then creates a SessionFactory object.

◆ creates a SessionFactory object based on the Configuration object. In order to create a SessionFactory object, you must create an instance of the Configuration class during Hibernate initialization and leave the written mapping file to it for processing.

In this way, the Configuration object can create a SessionFactory object, and when the SessionFactory object is created successfully, the Configuration object is useless, and you can simply discard it.

(2) it is the object that starts Hibernate

Although the Hibernate Configuration interface plays only a small role in the entire Hibernate project, it is the * * objects you encounter when you start hibernate.

(3) using the method chain programming style, it can be rewritten as follows:

Configuration config = new Configuration (); config.addClass (Customer.class); sessionFactory = config.buildSessionFactory ()

SessionFactory = new Configuration (). BuildSessionFactory ().

AddClass (Customer.class) .buildSessionFactory ()

Note: the method chain programming style makes the application code simpler. When using this programming style, * put each calling method on a different line, otherwise you cannot jump into each calling method when tracking the program.

Thank you for your reading, the above is the content of "what is Hibernate Configuration", after the study of this article, I believe you have a deeper understanding of what Hibernate Configuration is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report