Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get database version through 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.

like image 620
Yining Avatar asked Apr 21 '26 12:04

Yining


1 Answers

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.

like image 163
Paul Sasik Avatar answered Apr 23 '26 02:04

Paul Sasik