Get Hibernate version

    0

    0

    Michael Born

    The code uses the Java org.hibernate.Version class to get the version of Hibernate. If the version is not the same as what is specified in the Lucee's custom Hibernate jar, then it simply returns the version string from the org.hibernate.Version class. If the version is the same but the jar was poorly packaged, then the code uses the class loader to get the version from the bundle and then returns that version.

    Shortcut: gethibernateVersion

      /**
      * Work around the insanity of Lucee's custom Hibernate jar,
      * which has a bad MANIFEST.MF with no specified `Implementation-Version` config.
      */
    public string function getHibernateVersion(){
      var version = createObject( "java", "org.hibernate.Version" );
      
      if ( version.getVersionString() != "[WORKING]" ) {
      return version.getVersionString();
      } else {
        // Differing code path for poorly packaged Lucee bundles which mangle the manifest version
      return version
        .getClass()
        .getClassLoader()
        .getBundle()
        .getVersion()
        .toString();
      }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.