Creating A SessionFactory In Hibernate 4
In Hibernate 4, Configuration.buildSessionFactory is deprecated in a favor of a new overload which builds a SessionFactory using a Service Registry.
Configuration cfg = new Configuration();
cfg.configure();
ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
builder.applySettings(cfg.getProperties());
ServiceRegistry sr = builder.buildServiceRegistry();
cfg.buildSessionFactory(sr);
This comes in handy if you need to manually create a SessionFactory (aren't using JPA).
Written by Dixon Whitmire
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Hibernate
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#