Home > Back-end >  Default version of Hibernate used in Java EE 8 / JSF-2.3 / Wildfly-26 project
Default version of Hibernate used in Java EE 8 / JSF-2.3 / Wildfly-26 project

Time:05-17

How can I find exact version of default Hibernate version in my project with these configs:

  • Java EE 8
  • Java version "17"
  • Apache-Maven-3.8.2
  • Eclipse IDE Version: 2022-03 (4.23.0)
  • Wildfly-26.1.0.Final

pom.xml file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>example</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </properties>
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>8.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>2.1.212</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.3.2</version>
            </plugin>
        </plugins>
    </build>
</project>

I also check this link but does not help me: LINK

And even this code snippet has error:

System.out.println(org.hibernate.annotations.common.Version.VERSION);

org.hibernate cannot be resolved to a variable

CodePudding user response:

You are not using Hibernate but JPA. The hibernate version is set in the WildFly pom.xml https://github.com/wildfly/wildfly/blob/26.1.0.Final/pom.xml#L418 for WildFly 26.1.0.Final

CodePudding user response:

Try

System.out.println(org.hibernate.Version.getVersionString());

or

package com.test;
public class TestBean {
public static void main(String[] args) {
    try {
        String hibernateVersion = org.hibernate.annotations.common.Version.VERSION;
        System.out.println("Hibernate Version: "  hibernateVersion);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
}
  • Related