daily pastebin goal
35%
SHARE
TWEET

Untitled

Tanapone Oct 3rd, 2017 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.springmvc.model;
  2.  
  3. import java.util.Properties;
  4. import org.hibernate.SessionFactory;
  5. import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
  6. import org.hibernate.cfg.Configuration;
  7.  
  8. public class HibernateConnection {
  9.     public static SessionFactory sessionFactory;
  10.  
  11.     public static SessionFactory doHibernateConnection() {
  12.         Properties database = new Properties();
  13.         database.setProperty("hibernate.connection.driver_class", "oracle.jdbc.driver.OracleDriver");
  14.         database.setProperty("hibernate.connection.username", "project");
  15.         database.setProperty("hibernate.connection.password", "123456");
  16.         database.setProperty("hibernate.connection.url", "jdbc:oracle:thin:@192.168.1.26:1521:xe");
  17.         database.setProperty("hibernate.dialect", "org.hibernate.dialect.Oracle10gDialect");
  18.         Configuration cfg = new Configuration();
  19.         cfg.setProperties(database).addPackage("model").addAnnotatedClass(UsersBean.class);
  20.         cfg.setProperties(database).addPackage("model").addAnnotatedClass(UserProfileBean.class);
  21.         cfg.setProperties(database).addPackage("model").addAnnotatedClass(UserTypeBean.class);
  22.         StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder().applySettings(cfg.getProperties());
  23.         sessionFactory = cfg.buildSessionFactory(ssrb.build());
  24.         return sessionFactory;
  25.     }
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top