Guest User

Hibernate.java

a guest
Sep 20th, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. package com.jayan;
  2.  
  3. import org.hibernate.SessionFactory;
  4. import org.hibernate.cfg.Configuration;
  5.  
  6. public class Hibernate{
  7.  private static final SessionFactory sessionFactory = buildSessionFactory();
  8.  private static SessionFactory buildSessionFactory() {
  9.   try {
  10.    // Create the SessionFactory from hibernate.xml
  11.    return new Configuration().configure().buildSessionFactory();
  12.   }
  13.   catch (Throwable ex) {
  14.    // Make sure you log the exception, as it might be swallowed
  15.    System.err.println("Initial SessionFactory creation failed." + ex);
  16.    throw new ExceptionInInitializerError(ex);
  17.   }
  18.  }
  19.  public static SessionFactory getSessionFactory() {
  20.   return sessionFactory;
  21.  }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment