Skip to content

Instantly share code, notes, and snippets.

@Guvenir
Created November 24, 2015 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Guvenir/b7c16b23aeddcae2220d to your computer and use it in GitHub Desktop.
Save Guvenir/b7c16b23aeddcae2220d to your computer and use it in GitHub Desktop.
Hibernate SessionFactory
import org.hibernate.SessionFactory;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
public class SesFactory {
public static SessionFactory getSessionFactory(){
final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
.configure() // configures settings from hibernate.cfg.xml
.build();
return new MetadataSources(registry).buildMetadata().buildSessionFactory();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment