问题
I am migrating my application to Hibernate 5 from Hibernate 3. We are using DatabaseMetadata
class to get TableMetadata
. Hence using TableMetadata
object to get DB table column information like column size, type..etc. It seems in Hibernate 5 DatabaseMetadata
class got deprecated (removed!). Are there any alternatives for DatabaseMetadata
class in Hibernate 5? Or else how to get TableMetadata
in Hibernate 5 env?
回答1:
It got removed in 5.0 as we moved to a new approach to schema tooling. DatabaseMetadata represented the existing catalog/schema information from the underlying database. In 5.0 that role is served by org.hibernate.tool.schema.extract.spi.DatabaseInformation
. That (and DatabaseMetadata before it) are really supported just for use in schema validation and schema migration (update) code. It is passed into those calls. I assume you are using this is a different way. That is not necessarily supported, but if you want to continue that anyway, you'd just instantiate a org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl
instance.
来源:https://stackoverflow.com/questions/33694436/migrating-to-hibernate-5-x