The reasons for this are explained in Hibernate Jira
https://hibernate.onjira.com/browse/HHH-2578
Currently, a SessionFactory is created by throwing a bunch of stuff into the configuration object, stirring it, letting it boil, and then pulling out the SessionFactory. Seriously, there are several problems with the way we are currently working in the configuration and how we use it to create a SessionFactory: The general problem is that there is no “life cycle” when various pieces of information will be available. This is an important omission in several ways: 1) consider creating a circuit. currently we can’t even know the dialect when the set of db object names is defined. this would be good because it would allow us to transparently handle the names of tables and columns, which are also keywords / reserved words in the dialect. 2) the static types and types of mappings. Because we currently have nothing to cover them. Ideally, an instance of a type should know the SessionFactory with which it is associated. Instead, what we have now is to change the API methods quite a while to add to the SessionFactory as the passed parameter whenever it is found to be necessary. 3) also, most (all?) Of the “Static” configuration parameters in Hibernate are currently required due to their use from within these static types; thus, coverage types also allow us to have such configuration parameters (such as byteecode-provider, use of binary streams, etc.). Ideally, what I see is a scheme in which users create their own instance of org.hibernate.cfg.Settings (or something similar). In addition, they will apply metadata to some registry (let's call it MetadataRegistry at the moment). Then, to build a SessionFactory, they will supply these two pieces of information (via ctor? Via the builder?). An important aspect is that the information in MetadataRegistry will not be considered until this point, which will allow us to guarantee that the resolution of object names, types, etc. Will have access to runtime settings (and, in particular, the dialect)
You can also read comments on this subject: https://hibernate.onjira.com/browse/HHH-7580 There is too much of it to copy paste, and I think that Jira will not go down, so this answer should be valid.
Marek
source share