Configuration()类是抽象的,不能被实例化

时间:2018-02-15 14:44:37

标签: java hibernate configuration sessionfactory

当我使用Configration类构建sessionFactory时,它表示该类是抽象的,无法实现,并希望我实现返回AppConfigurationEntry []的方法getAppConfigurationEntry!

这是我的代码:

public class BookDAOImp implements GeneralDAO<Book, String> {

    private static SessionFactory sessionFactory;
    private static ServiceRegistry serviceRegistry;

    public BookDAOImp() {
    }

    public static SessionFactory createSessionFactory() {
        Configuration configuration = new Configuration();
        configuration.configure();
        ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(
                configuration.getProperties()).buildServiceRegistry();
        sessionFactory = configuration.buildSessionFactory(serviceRegistry);
        return sessionFactory;
    }
}

你能帮助我解决这个小小的误会吗? 任何正文都可以帮我用这个函数或其他方法构建sessionFactory吗?

0 个答案:

没有答案