Diferencia entre revisiones de «Usuario:Lmorillas/desarrollo web servidor/jee/intro hibernate»
De WikiEducator
(→BuildSessionFactory) |
(→BuildSessionFactory) |
||
Línea 28: | Línea 28: | ||
== BuildSessionFactory == | == BuildSessionFactory == | ||
<source lang="java"> | <source lang="java"> | ||
− | + | import org.hibernate.service.ServiceRegistry; | |
− | + | import org.hibernate.service.ServiceRegistryBuilder; | |
− | + | ||
− | + | // ... | |
− | + | ||
− | + | ||
− | sessionFactory = | + | SessionFactory sessionFactory = new org.hibernate.cfg.Configuration(). |
− | + | configure().buildSessionFactory(); | |
+ | |||
+ | // ... | ||
+ | |||
+ | Configuration configuration = new Configuration(); | ||
+ | configuration.configure(); | ||
+ | |||
+ | ServiceRegistry serviceRegistry = new ServiceRegistryBuilder(). | ||
+ | applySettings(configuration.getProperties()).buildServiceRegistry(); | ||
+ | SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry); | ||
</source> | </source> |
Revisión de 23:12 30 ene 2013
Objetivos
Tareas
Guión
|
BuildSessionFactory
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistryBuilder; // ... SessionFactory sessionFactory = new org.hibernate.cfg.Configuration(). configure().buildSessionFactory(); // ... Configuration configuration = new Configuration(); configuration.configure(); ServiceRegistry serviceRegistry = new ServiceRegistryBuilder(). applySettings(configuration.getProperties()).buildServiceRegistry(); SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);