如何通过Hibernate获取数据库版本? [英] How to get database version through Hibernate?
问题描述
获取数据库引擎的版本是特定于实现的。这意味着没有获取版本的共享方法,所以Hibernate无法真正提供API,因为它不绑定到任何特定的RDBMS。例如,您可以通过一些不同的方式从一些知名的RDBMS获取SELECT语句的版本: strong>:SELECT * FROM v $ version;
您可以创建查看报告的版本,然后将其添加到您的ORM中,然后将其作为任何其他Hibernate对象访问。
Is there a way to get some information of the underlying database version through the Hibernate 3.2 API? I failed to find relevant bits both here and the javadoc.
Getting the version of your database engine is implementation specific. This means that there's no shared method for getting the version and so Hibernate cannot really provide an API since it is not bound to any particular RDBMS. For example, here are some different ways you get the version with SELECT statements from some well-known RDBMSs:
- Oracle: SELECT * FROM v$version;
- SQL Server: SELECT @@version
- MySQL: SELECT VERSION()
- ...
You could create a view that reports the version and then add that to your ORM which would then be accessible as any other Hibernate object.
这篇关于如何通过Hibernate获取数据库版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!