Before sleep mode 4
The way to implement a session connection is with SessionFactory only.
Example:
Configuration cfg=new Configuration();
Configuration cfg=cfg.configure("mysql.cfg.xml");
SessionFactory sf=cfg1.buildSessionFactory();
Hibernate 4.0.4.1.4.2
It changes with the ServiceRegistry concept, and the implementation method with ServiceRegistry and SessionFactory.
Example:
Configuration configuration = new Configuration();
configuration.configure();
serviceRegistry = new ServiceRegistryBuilder().applySettings(
configuration.getProperties()).build();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
Hibernate 4.3
ServiceRegistryBuilder () is also deprecated and replaced by the standard ServiceRegistryBuilder ().
Example:
serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
configuration.getProperties()).build();
My questions:
- What is the difference between b / w SessionFactory and ServiceRegistry?
- Why is the concept of ServiceRegistry required?
- What is the advantage of deploying ServiceRegistry on top of SessionFactory?
- What is the difference between b / w ServiceRegistryBuilder () and StandardServiceRegistryBuilder ()?
source
share