【问题标题】:Hibernate4 openSession()Hibernate4 openSession()
【发布时间】:2014-06-21 15:16:50
【问题描述】:

我正在开发一个使用 Hibernate 框架 (v4.3.4) 的应用程序。当我运行测试时,我得到以下异常:

Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
    at com.cartif.dwhconnector.manager.DatabaseCommunicator.createDBSession(DatabaseCommunicator.java:89)
    at com.cartif.dwhconnector.manager.DWHManager.createDBSession(DWHManager.java:53)
    at unittest.DWHConnectorTester.main(DWHConnectorTester.java:16)

Java代码是下一个:

Configuration configuration = new Configuration();
configuration.configure("com/cartif/hibernatemappings/hibernate.cfg.xml");
SessionFactory sessionFactory = configuration.buildSessionFactory();
session = sessionFactory.openSession();

我尝试使用包 org.hibernate 和 org.hibernate.clasic 中的 Session 类,但异常总是相同的。你能帮帮我吗?

提前谢谢你!

【问题讨论】:

标签: java hibernate


【解决方案1】:

您可能在测试期间使用不同版本的 Hibernate,在应用程序编译期间使用不同版本。

【讨论】:

    猜你喜欢
    • 2021-07-25
    • 2011-12-24
    • 2015-11-12
    • 2012-02-01
    • 2014-03-10
    • 2016-04-20
    • 1970-01-01
    • 1970-01-01
    • 2012-10-16
    相关资源
    最近更新 更多