List of usage examples for org.hibernate.cfg Configuration buildSessionFactory
public SessionFactory buildSessionFactory() throws HibernateException
From source file:com.imos.sample.util.HibernateUtil.java
private static SessionFactory configure() throws HibernateException { try {/*from ww w . j a v a2s . c o m*/ Configuration configuration; // Configuration configuration = new Configuration()l //// .addAnnotatedClass(Person.class) //// .addAnnotatedClass(Address.class) // .addAnnotatedClass(UserDetailOTO.class) // .addAnnotatedClass(UserDetailOTM.class) // .addAnnotatedClass(UserDetailMTM.class) // .addAnnotatedClass(VehicleOTO.class) // .addAnnotatedClass(VehicleOTM.class) // .addAnnotatedClass(VehicleMTM.class) // // .setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver") // .setProperty("hibernate.connection.username", "root") // .setProperty("hibernate.connection.password", "invicara") // .setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/sampledb?autoReconnect=true&useSSL=false") // .setProperty("hibernate.connection.pool_size", "1") // .setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect") // .setProperty("hibernate.show_sql", "true") // .setProperty("hibernate.hbm2ddl.auto", "update"); // // sessionFactory = configuration.buildSessionFactory(); configuration = new Configuration().configure("hibernate_sampledb.cfg.xml"); sessionFactorySampleDB = configuration.buildSessionFactory(); // configuration = new Configuration() // .configure("hibernate_skilldb.cfg.xml"); // // sessionFactorySkillDB = configuration.buildSessionFactory(); sessionFactory = sessionFactorySampleDB; } catch (Exception e) { log.severe(e.getMessage()); System.exit(0); return null; } return sessionFactory; }
From source file:com.induscorp.prime.testing.ui.core.config.database.DatabaseQueryHandler.java
License:Open Source License
public DatabaseQueryHandler(String hibernateCfgFile) { Configuration hibernateCfg = new Configuration().configure(new File(hibernateCfgFile)); hibernateSessionFactory = hibernateCfg.buildSessionFactory(); }
From source file:com.ironiacorp.persistence.datasource.HibernateTest.java
License:Apache License
@Before public void setUp() throws Exception { HibernateDataSource bootstrap = new HibernateDataSource(); Configuration config = bootstrap.getConfig(); sessionFactory = config.buildSessionFactory(); }
From source file:com.jdon.persistence.hibernate.AnnotationConfFactory.java
License:Apache License
public void createSessionFactory() { try {//www. j a va 2s. c o m Configuration configuration = null; if ((hibernate_cfg_xml != null) && (hibernate_cfg_xml.length() != 0)) { configuration = new AnnotationConfiguration().configure(hibernate_cfg_xml); } else { configuration = new AnnotationConfiguration().configure(); } this.sessionFactory = configuration.buildSessionFactory(); } catch (HibernateException e) { logger.error("Hibernate Annotation start error: " + e); } }
From source file:com.jdon.persistence.hibernate.ConfFactory.java
License:Apache License
public void createSessionFactory() { try {//from w w w. ja v a2s . c o m Configuration configuration = null; if ((hibernate_cfg_xml != null) && (hibernate_cfg_xml.length() != 0)) { configuration = new Configuration().configure(hibernate_cfg_xml); } else { configuration = new Configuration().configure(); } this.sessionFactory = configuration.buildSessionFactory(); } catch (HibernateException e) { logger.error("Hibernate start error: " + e); } }
From source file:com.jdon.persistence.hibernate.util.ThreadLocalSessionProvider.java
License:Apache License
/** * Constructor for the ThreadLocalSessionProvider object * * @param sfp Description of Parameter/*from www .j a va2 s . c o m*/ */ public ThreadLocalSessionProvider(Configuration cfg) { _factory = cfg.buildSessionFactory(); }
From source file:com.jklas.search.HibernateHydrateTest.java
License:Open Source License
@BeforeClass public static void setupSessionFactory() throws SearchEngineMappingException { Utils.configureAndMap(Customer.class); Utils.configureAndMap(Item.class); HibernateEventInterceptor listener = new HibernateEventInterceptor(new SearchInterceptor( new DefaultIndexerService(new DefaultIndexingPipeline(), MemoryIndexWriterFactory.getInstance()))); Configuration configuration = new Configuration().configure(); configuration.getEventListeners().setPreInsertEventListeners(new PreInsertEventListener[] { listener }); configuration.getEventListeners().setPreUpdateEventListeners(new PreUpdateEventListener[] { listener }); configuration.getEventListeners().setPreDeleteEventListeners(new PreDeleteEventListener[] { listener }); sessionFactory = configuration.buildSessionFactory(); }
From source file:com.leqienglish.util.SessionBulder.java
/** * ? Session// w w w . j a va 2 s. c om * @return */ private static Session getSession() { if (sessionFactory == null) { // Configuration--?Hibernate.properties Configuration configuration = new Configuration(); // --?Xxx.hbm.xml configuration.configure(); // SessionFactory sessionFactory = configuration.buildSessionFactory(); } return sessionFactory.openSession(); }
From source file:com.liferay.samplehibernate.util.HibernateUtil.java
License:Open Source License
private HibernateUtil() { try {/*from w w w . j a v a2s .co m*/ Configuration configuration = new Configuration(); configuration = configuration.configure(); _sessionFactory = configuration.buildSessionFactory(); } catch (Exception e) { _log.error(e, e); } }
From source file:com.mangium.Moharto_Login_Check.java
public String valid() { System.out.println("-------------------Login Check ---------"); String logincheck = ""; Configuration cfg = new Configuration(); cfg.configure("hibernate.cfg.xml"); SessionFactory sf = cfg.buildSessionFactory(); Session session = sf.openSession();// ww w.ja v a 2s. c o m Query q = session.createQuery("from com.mangium.Moharto_Login_Bean "); ArrayList list = (ArrayList) q.list(); Iterator it = list.iterator(); Moharto_Student_Register_Basic_Bean u = null; while (it.hasNext()) { u = (Moharto_Student_Register_Basic_Bean) it.next(); if (u.equals(null)) { logincheck = "login"; System.out.println("-------------------Login Failed---------"); break; } if (user.getEmail().equals(u.getEmail())) { if (user.getPassword().equals(u.getPassword())) { System.out.println("-------------------Login Successfull---------"); logincheck = "success"; } else { logincheck = "login"; System.out.println("-------------------Login Failed---------"); } } } session.close(); sf.close(); return null; }