如何通过Hibernate获取数据库版本? [英] How to get database version through Hibernate?

查看:116
本文介绍了如何通过Hibernate获取数据库版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法通过Hibernate 3.2 API获取底层数据库版本的一些信息?我没有在这里和javadoc找到相关的位。

解决方案

获取数据库引擎的版本是特定于实现的。这意味着没有获取版本的共享方法,所以Hibernate无法真正提供API,因为它不绑定到任何特定的RDBMS。例如,您可以通过一些不同的方式从一些知名的RDBMS获取SELECT语句的版本: strong>:SELECT * FROM v $ version;

  • SQL Server :SELECT @@ version

  • MySQL :SELECT 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屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆