Hibernate - ServiceRegistryBuilder

前端 未结 9 1895
眼角桃花
眼角桃花 2020-12-28 08:30

I\'m just trying to learn Hibernate (version 4 final) but I have a problem when trying to create the session factory. Here is some code related to the problem:

hi

9条回答
  •  眼角桃花
    2020-12-28 08:54

    I encountered similar problems trying to use Hibernate 4.1.6.

    Building on an example from RoseIndia.net, I got ServiceRegistryBuilder working like this:

    Configuration config = new Configuration();
    config.configure();
    ServiceRegistryBuilder srBuilder = new ServiceRegistryBuilder();
    srBuilder.applySettings(config.getProperties());
    ServiceRegistry serviceRegistry = srBuilder.buildServiceRegistry();
    SessionFactory factory = config.buildSessionFactory(serviceRegistry);
    

    My hibernate.cfg.xml file uses the old DTD file; I have not been able to get the new XSD file to be recognized by Hibernate 4.1.6:

    
    
    
        
            ...
        
    
    

    Perhaps you can adapt this to work for you?

提交回复
热议问题