简体   繁体   中英

What is the difference between Configuration vs ServiceRegistry vs StandardServiceRegistry?

I'm new to Hibernate and I want to know if Configuration class is already there, then why we need ServiceRegistry and StandardServiceRegistry?

Why should I use ServiceRegistry and StandardServiceRegistry?

What are the advantages over Configuration class?

Should I use configuration class?

These are two ways to bootstrap Hibernate: the Configuration is the legacy way , while the ServiceRegistry way is the recommended way starting Hibernate 5. Worth noting the following from the linked documentation:

There are some significant drawbacks to the legacy bootstrapping mechanism which led to its deprecation and the development of the new approach, which is discussed in Native Bootstrapping.

Configuration is semi-deprecated but still available for use, in a limited form that eliminates these drawbacks. "Under the covers", Configuration uses the new bootstrapping code, so the things available there are also available here in terms of auto-discovery.

As for the disadvantages, the best source is probably this Jira issue where they explain the rationale behind the redesign of the SessionFactory bootstrapping, which I believe mostly facilitates the ability to extend the framework.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM