3

Question pretty much says it all.

Is there an equivalent for org.hibernate.Version.getVersionString() in EclipseLink?

Why isn't there a portable (JPA) way to query provider information in general?

Kawu
  • 13,647
  • 34
  • 123
  • 195
  • Why there isn't a JPA way of doing that is a question for the JPA "expert group". JDO provides a mechanism for getting the version of JDO implementations – DataNucleus Mar 08 '12 at 15:30

2 Answers2

6

Never used it but from the Eclipselink javadoc you could try the following class:

org.eclipse.persistence.Version

Matt Handy
  • 29,855
  • 2
  • 89
  • 112
  • Unfortunately Eclipselink is not well documented. I would like to RTFM if there was any ;-) – Matt Handy Mar 08 '12 at 18:39
  • Doesn't work for me... (Package org.eclipse.persistence does not exist) I'm using Glassfish 4.1 and don't know in which library eclipselink is buried. Maybe in javaee-endorsed-api-7.0.jar or in javaee-web-api. Any idea how my web-app can query the eclipselink version? Thanks in advance. – Pierre C Apr 15 '15 at 02:31
  • 2
    @PierreC, the same thing happened to me: EclipseLink is provided by the runtime but since it's not available at compile time, the package doesn't exist. Solution: use reflection, like this: Class> myClass = Class.forName("org.eclipse.persistence.Version"); Method myMethod = myClass.getMethod("getVersion"); String version = myMethod.invoke(null).toString(); – José Ernesto Lara Rodríguez Jun 18 '15 at 15:23
0

There is a static class and static method to get this information.

Example: How to print in java code

AbstractSessionLog.getLog().log(SessionLog.INFO, DatabaseLogin.getVersion());
Gaurav Gharat
  • 1,921
  • 1
  • 10
  • 5