相关疑难解决方法(0)

项目中hibernate.cfg.xml的位置?

我创建了一个具有以下结构的项目:

在此输入图像描述

HibernateUtil中:

public class HibernateUtil {

    private static final SessionFactory sessionFactory = buildSessionFactory();

    private static SessionFactory buildSessionFactory() {
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            Configuration  configuration = new Configuration().configure( "C:\\Users\\Nikolay_Tkachev\\workspace\\hiberTest\\src\\logic\\hibernate.cfg.xml");
            return new Configuration().configure().buildSessionFactory();
        } catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }

    public static void shutdown() {
        // Close caches and …
Run Code Online (Sandbox Code Playgroud)

java orm hibernate

21
推荐指数
2
解决办法
10万
查看次数

标签 统计

hibernate ×1

java ×1

orm ×1