List of usage examples for org.hibernate.cfg Configuration Configuration
public Configuration()
From source file:com.openjmsadapter.configuration.database.DatabaseConfigHolder.java
License:Open Source License
public DatabaseConfigHolder(String filename) { logger.debug("Creating hibernate session factory"); this.sessionFactory = new Configuration().configure(new File(filename)).buildSessionFactory(); buildConfig();/*from ww w .ja v a2 s .c o m*/ logger.debug("Created hibernate session factory"); }
From source file:com.openkm.dao.HibernateUtil.java
License:Open Source License
/** * Construct annotation configuration//from w w w. j ava 2 s .c o m */ private static Configuration getConfiguration() { Configuration cfg = new Configuration(); // Add annotated beans cfg.addAnnotatedClass(Activity.class); cfg.addAnnotatedClass(Bookmark.class); cfg.addAnnotatedClass(MimeType.class); cfg.addAnnotatedClass(DatabaseMetadataType.class); cfg.addAnnotatedClass(DatabaseMetadataValue.class); cfg.addAnnotatedClass(DatabaseMetadataSequence.class); cfg.addAnnotatedClass(WikiPage.class); cfg.addAnnotatedClass(ZohoToken.class); cfg.addAnnotatedClass(com.openkm.dao.bean.Config.class); cfg.addAnnotatedClass(Profiling.class); cfg.addAnnotatedClass(DashboardActivity.class); cfg.addAnnotatedClass(Css.class); cfg.addAnnotatedClass(Omr.class); cfg.addAnnotatedClass(PendingTask.class); // Cache cfg.addAnnotatedClass(UserItems.class); cfg.addAnnotatedClass(UserNodeKeywords.class); // Automation cfg.addAnnotatedClass(AutomationRule.class); cfg.addAnnotatedClass(AutomationValidation.class); cfg.addAnnotatedClass(AutomationAction.class); // New Persistence Model cfg.addAnnotatedClass(NodeBase.class); cfg.addAnnotatedClass(NodeDocument.class); cfg.addAnnotatedClass(NodeDocumentVersion.class); cfg.addAnnotatedClass(NodeFolder.class); cfg.addAnnotatedClass(NodeMail.class); cfg.addAnnotatedClass(NodeNote.class); cfg.addAnnotatedClass(NodeLock.class); cfg.addAnnotatedClass(NodeProperty.class); cfg.addAnnotatedClass(RegisteredPropertyGroup.class); //.. cfg.addAnnotatedClass(MailImportError.class); cfg.addAnnotatedClass(Plugin.class); return cfg; }
From source file:com.openkm.hibernate.HibernateUtil.java
License:Open Source License
/** * Get instance//from w w w .j ava 2 s . c om */ public static SessionFactory getSessionFactory() { Configuration cfg = new Configuration(); return getSessionFactory(cfg); }
From source file:com.openkm.hibernate.search.SearchTest.java
License:Open Source License
@Override protected void setUp() { log.debug("setUp()"); Configuration cfg = new Configuration(); cfg.addAnnotatedClass(Document.class); SessionFactory sf = HibernateUtil.getSessionFactory(cfg); assertNotNull(sf);/*from w w w.java2 s . c o m*/ }
From source file:com.openwords.database.DatabaseHandler.java
License:Open Source License
private DatabaseHandler() { String host = "127.0.0.1"; String port = "3306"; String username = "root"; String password = "han"; String dbName = "openwordsdb"; Configuration configuration = new Configuration(); configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect"); configuration.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver"); configuration.setProperty("hibernate.connection.url", "jdbc:mysql://" + host + ":" + port + "/" + dbName + "?autoReconnect=true"); configuration.setProperty("hibernate.connection.username", username); configuration.setProperty("hibernate.connection.password", password); configuration.setProperty("hibernate.connection.characterEncoding", "utf-8"); //configuration.setProperty("hibernate.format_sql", "true"); //configuration.setProperty("hibernate.show_sql", "true"); configuration.setProperty("hibernate.connection.provider_class", "org.hibernate.c3p0.internal.C3P0ConnectionProvider"); configuration.setProperty("hibernate.c3p0.idleConnectionTestPeriod", "600"); configuration.setProperty("hibernate.c3p0.testConnectionOnCheckin", "true"); configuration.addAnnotatedClass(UserInfo.class).addAnnotatedClass(Lesson.class) .addAnnotatedClass(Course.class).addAnnotatedClass(Sound.class).addAnnotatedClass(Comment.class) .addAnnotatedClass(Stats.class); sessionFactory = configuration.buildSessionFactory( new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build()); sessionFactory.getStatistics().setStatisticsEnabled(true); UtilLog.logInfo(DatabaseHandler.class, "SessionFactory created"); }
From source file:com.oracle.coherence.hibernate.cache.CoherenceHibernateSecondLevelCachePerformanceTest.java
License:CDDL license
/** * Returns a new Hibernate Session.// www. j a v a 2 s . com * * @param hibernateConfigFilePath the path to the Hibernate configuration file to use * * @return a Session */ private Session newSession(String hibernateConfigFilePath) { if (sessionFactory == null) sessionFactory = new Configuration().configure(hibernateConfigFilePath).buildSessionFactory(); return sessionFactory.openSession(); }
From source file:com.oracle.coherence.hibernate.cachestore.HibernateCacheLoader.java
License:CDDL license
/** * Constructor which accepts an entityName. Configures Hibernate using * the default Hibernate configuration. The current implementation parses * this file once-per-instance (there is typically a single instance per). * * @param sEntityName the Hibernate entity (i.e., the HQL table name) *//*from w w w. ja va 2 s . c o m*/ public HibernateCacheLoader(String sEntityName) { m_sEntityName = sEntityName; // Configure using the default Hibernate configuration. Configuration configuration = new Configuration(); configuration.configure(); m_sessionFactory = configuration.buildSessionFactory(); }
From source file:com.oracle.coherence.hibernate.cachestore.HibernateCacheLoader.java
License:CDDL license
/** * Constructor which accepts an entityName and a Hibernate configuration * resource. The current implementation instantiates a SessionFactory per * instance (implying one instance per CacheStore-backed NamedCache). * * @param sEntityName Hibernate entity (i.e. the HQL table name) * @param sResource Hibernate config classpath resource (e.g. hibernate.cfg.xml) *//*from ww w .j a va 2 s. c o m*/ public HibernateCacheLoader(String sEntityName, String sResource) { m_sEntityName = sEntityName; /* If we start caching these we need to be aware that the resource may be relative (and so we should not key the cache by resource name). */ Configuration configuration = new Configuration(); configuration.configure(sResource); m_sessionFactory = configuration.buildSessionFactory(); }
From source file:com.oracle.coherence.hibernate.cachestore.HibernateCacheLoader.java
License:CDDL license
/** * Constructor which accepts an entityName and a Hibernate configuration * resource. The current implementation instantiates a SessionFactory per * instance (implying one instance per CacheStore-backed NamedCache). * * @param sEntityName Hibernate entity (i.e. the HQL table name) * @param configurationFile Hibernate config file (e.g. hibernate.cfg.xml) *///from w ww . j a v a 2 s . c om public HibernateCacheLoader(String sEntityName, File configurationFile) { m_sEntityName = sEntityName; /* If we start caching these we should cache by canonical file name. */ Configuration configuration = new Configuration(); configuration.configure(configurationFile); m_sessionFactory = configuration.buildSessionFactory(); }
From source file:com.oracle.rsp.tcsettings.dao.SettingDao.java
private SessionFactory configureSessionFactory() throws HibernateException { Configuration configuration = new Configuration(); configuration.configure();//from ww w . j a v a 2 s . com Properties properties = configuration.getProperties(); serviceRegistry = new ServiceRegistryBuilder().applySettings(properties).buildServiceRegistry(); sessionFactory = configuration.buildSessionFactory(serviceRegistry); return sessionFactory; }