Java 休眠版?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3480608/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 01:09:54  来源:igfitidea点击:

Hibernate version?

javahibernateorm

提问by Kawu

I'm using JBoss Embeddedversion beta3.SP10 and I'm facing a persistence bug that is should be fixed in some Hibernate version. Sadly, I don't know what version of Hibernate is used in my JBoss Embedded and couldn't find a way to find this information, the hibernate-all.jarbundled in it doesn't contain a org.hibernate.Versionclass, nor a MANIFEST.

我正在使用JBoss Embedded版本 beta3.SP10,但我正面临一个持久性错误,该错误应该在某些 Hibernate 版本中修复。可悲的是,我不知道我的 JBoss Embedded 中使用了什么版本的 Hibernate,也找不到找到此信息的方法,其中hibernate-all.jar捆绑的不包含 org.hibernate.Version类,也不包含 MANIFEST。

How can I find the currently loaded Hibernate version without using org.hibernate.Version?

如何在不使用的情况下找到当前加载的 Hibernate 版本org.hibernate.Version

采纳答案by max3d

Try this,

尝试这个,

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

found here

在这里找到

回答by Pascal Thivent

Indeed, it seems hard to find what exact versions of Hibernate modules are used. Some suggestions:

事实上,似乎很难找到使用的 Hibernate 模块的确切版本。一些建议:

  1. Check if your Hibernate JAR has a META-INF/MANIFEST.MFwith the version in it.It looks like the JBoss folks were using Ant at this time and the Manifest doesn't provide the version.

  2. Dig the JBoss Embedded SVNto find out what they're doing exactly.

  3. Try with JBoss embedded beta3.SP12(that you can get from the Maven repository).

  4. Try to replace the hibernate-all with a bundle containing Hibernate EM 3.4.0.GA.

  1. 检查您的 Hibernate JAR 中是否META-INF/MANIFEST.MF包含该版本。看起来 JBoss 的人此时正在使用 Ant,而 Manifest 没有提供版本。

  2. 深入研究JBoss Embedded SVN以了解他们在做什么。

  3. 尝试使用JBoss 嵌入式 beta3.SP12(您可以从 Maven 存储库中获取)。

  4. 尝试用包含 Hibernate EM 3.4.0.GA 的包替换 hibernate-all。

I would give options 3 and 4 a try.

我会尝试一下选项 3 和 4。

回答by UdayKiran Pulipati

This simple Java code is get the Hibernate version.

这个简单的 Java 代码就是获取 Hibernate 版本。

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();
    }
}
}

Output:Hibernate Version: 3.1.0.GA

输出:Hibernate Version: 3.1.0.GA

回答by WesternGun

I prefer the way of @Shell, not that of @pudaykiran. Actually, I found these two way get different input in my case. As said @pudaykiran, I got:

我更喜欢@Shell 的方式,而不是@pudaykiran 的方式。实际上,我发现这两种方式在我的案例中得到了不同的输入。正如@pudaykiran 所说,我得到了:

3.2.0 Final

3.2.0 决赛

And as @Shell said:

正如@Shell 所说:

3.5.4 Final

3.5.4 决赛

I guess the 3.5.4 final version used org.hibernate.annotations.commonof previous version. Correct me if I am wrong.

我猜org.hibernate.annotations.common是以前版本使用的 3.5.4 最终版本。如果我错了,请纠正我。

回答by g5thomas

Another way to obtain the version.

另一种获取版本的方法。

System.out.println(org.hibernate.cfg.Environment.VERSION)

This is for older version of Hibernate. e.g. 3.3.1.GA

这适用于较旧版本的 Hibernate。例如 3.3.1.GA