There is a migration guide:
It is still a work in progress as in its is not "prettified" yet (as 5.0 is
not final yet. If things are missing please let us know.
Some answers inline...
- In Hibernate4 we modified mappings on-the-fly by overriding Spring's
Doing so we could first access the getClassMapping on
org.hibernate.cfg.Configuration before letting the SF actually build.
However, in Hibernate5 the metadata access has been refactored and is no
longer part of the Configuration. Should we use MetadataContributor instead
for these purposes?
Depends what you are trying to achieve specifically. What do you mean by
"modify"? Do you mean literally that you want to modify (alter) the
existing "class mappings", or do you really mean that you want to add
- Is there a way to register MetadataContributor dynamically? I see that it
is being loaded using Java's ServiceLoader.
However, I need some programmatic API access to enable or disable the
Contributor (for example based on Spring profiles).
No there is not a way to register a MetadataContributor programatically. I
really do not see the benefit of having that as a feature. Maybe you need
to explain better? But if a piece of code is able to determine whether or
not to register a MetadataContributor, it could simply contribute said
- For JTA integration we were using
this class is no longer present.
Also in org.hibernate.cfg.AvailableSettings the key that was used
(hibernate.transaction.factory_class) to configure the factory is also
Is hibernate.transaction.coordinator_class the new key we should be using
natorImpl as value for JTA?
Yes, but I would highly recommend using the short-name config values, e.g.:
Both do the same thing, the first form is just better (for many reasons).
Do we need to configure anything special in case of resource local TX
JdbcResourceLocalTransactionCoordinatorImpl the default?
I'm confused with this last piece in combination with the rest of the
questions here. The rest of the block discusses JTA, but then here you are
asking about JDBC-based transactions. Regardless, the default
TransactionCoordinator is in fact the JDBC one.
- generateDropSchemaScript and generateSchemaCreationScript have been
removed from Configuration. Is there a way to access this in another
Again, depends on exactly what you hope to accomplish here. Your main
options will be either:
1) grab the org.hibernate.tool.schema.spi.SchemaManagementTool from the
StandardServiceRegistry and use it to obtain the SchemaCreator
and SchemaDropper, passing them the Metadata.
2) Use the org.hibernate.tool.hbm2ddl.SchemaExport class