Package org.hibernate.cfg

Examples of org.hibernate.cfg.Configuration$ObjectNameNormalizerImpl


   * @param cfg_path
   */
  private Hibernate(String cfg_path){
    sessions = new ThreadLocal();
    transactions = new ThreadLocal();
    Configuration cfg = new Configuration().configure(new File(cfg_path));     
    sessionFactory = cfg.buildSessionFactory();
    this.hibernate_cfg = cfg_path;
  }
View Full Code Here


   * @throws HibernateException In case a problem occurred while configuring
   *         hibernate or creating the session factory.
   */
  private SessionHandler(Properties props) throws HibernateException {
    // reads in hibernate.properties implictly for database connection settings
    cfg = new Configuration();

    // attempt to use standard config file named hibernate.cfg.xml
    try {
      cfg.configure();
    } catch (HibernateException he) {
View Full Code Here

           * to make sure, even though right now, db access is used in the
           * single thread when starting up olat, and therefore the sync would
           * not be necessary
           */
          if (sessionFactory == null) {
            Configuration cfg = DatabaseSetup.datastoreConfiguration();

            // let all extensions add hibernate configuration, if needed
            ExtManager extm = null;
            try {
              extm = ExtManager.getInstance();
            } catch (Exception e) {
              throw new OLATRuntimeException(this.getClass(), "Can not load extensions. Check xml files.", e);
            }
            Class extensionPoint = this.getClass();
            int cnt = extm.getExtensionCnt();
            for (int i = 0; i < cnt; i++) {
              Extension anExt = extm.getExtension(i);
              HibernateConfigurator hibconfigure = (HibernateConfigurator) anExt.getExtensionFor(extensionPoint.getName());
              if (hibconfigure != null) {
                hibconfigure.extend(cfg);
                extm.inform(extensionPoint, anExt, "added hibernate configuration");
              }
            }

            // set audit interceptor that traces lastChanged
            cfg.setInterceptor(new AuditInterceptor());
            cfg.setProperties(getConnectionProperties());

            sessionFactory = cfg.buildSessionFactory();
            registerStatisticsServiceAsMBean(sessionFactory);
            try {
              String lev = "n/a";
              session = sessionFactory.openSession();
              int iso = session.connection().getTransactionIsolation();
View Full Code Here

   * @return Datastore
   *
   * @throws MappingException
   */
  public static Configuration datastoreConfiguration() throws MappingException {
    cf = new Configuration();
    List<String> filesAlreadyAdded = new ArrayList<String>();
    List<String> ignoredFiles = new ArrayList<String>();
   
    //TODO
    //loading hbm files out of a jar needs an start root directory. So change it to:
View Full Code Here

    */
   private void buildSessionFactory() throws Throwable
   {
      log.debug( "Building SessionFactory; " + this );

      Configuration cfg = new Configuration();
      cfg.getProperties().clear(); // avoid reading hibernate.properties and Sys-props

      // Handle custom listeners....
      ListenerInjector listenerInjector = generateListenerInjectorInstance();
      if ( listenerInjector != null )
      {
         listenerInjector.injectListeners( beanName, cfg );
      }

      // Handle config settings....
      transferSettings( cfg.getProperties() );

      // Handle mappings....
      handleMappings( cfg );

      // Handle interceptor....
      Interceptor interceptorInstance = generateInterceptorInstance();
      if ( interceptorInstance != null )
      {
         cfg.setInterceptor( interceptorInstance );
      }

      sessionFactoryProperties = new Properties(cfg.getProperties());
     
      // Generate sf....
      sessionFactory = cfg.buildSessionFactory();

      try
      {
         // Handle stat-mbean creation/registration....
         if ( controller != null && sessionFactory.getStatistics() != null && sessionFactory.getStatistics().isStatisticsEnabled() )
View Full Code Here

    return parameters;
  }

  private static Session createSession()
  {
    SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
   
    return sessionFactory.openSession();
  }
View Full Code Here

  private SessionFactory sessionFactory;

  public DefaultSessionProvider()
  {
    // Create the SessionFactory from hibernate.cfg.xml
    sessionFactory = new Configuration().configure().buildSessionFactory();
  }
View Full Code Here

    private static SessionFactory factory;

    public static synchronized Session getSession() {
        if (factory == null) {
            factory = new Configuration().configure().buildSessionFactory();
        }
        return factory.openSession();
    }
View Full Code Here

public class TestDayOfWeekStatHsqldbSchema extends TestCase {

  @Override
  protected void setUp() throws Exception {
    Configuration config = new Configuration().
    setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect").
    setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver").
    setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:baseball").
    setProperty("hibernate.connection.username", "sa").
    setProperty("hibernate.connection.password", "").
    setProperty("hibernate.connection.pool_size", "1").
    setProperty("hibernate.connection.autocommit", "true").
    setProperty("hibernate.cache.provider_class", "org.hibernate.cache.HashtableCacheProvider").
    setProperty("hibernate.hbm2ddl.auto", "create-drop").
    setProperty("hibernate.show_sql", "true").
    addClass(HourOfDayStat.class);

    HibernateUtil.setSessionFactory(config.buildSessionFactory());
   
    // uncomment the following if you want to launch a the dbmanager gui (while debugging through this class probably)
/*    Runnable r = new Runnable() {
      @Override
      public void run() {
View Full Code Here

public class TestDayOfWeekStatHsqldbSchema extends TestCase {

  @Override
  protected void setUp() throws Exception {
    Configuration config = new Configuration().
    setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect").
    setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver").
    setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:baseball").
    setProperty("hibernate.connection.username", "sa").
    setProperty("hibernate.connection.password", "").
    setProperty("hibernate.connection.pool_size", "1").
    setProperty("hibernate.connection.autocommit", "true").
    setProperty("hibernate.cache.provider_class", "org.hibernate.cache.HashtableCacheProvider").
    setProperty("hibernate.hbm2ddl.auto", "create-drop").
    setProperty("hibernate.show_sql", "true").
    addClass(DayOfWeekStat.class);

    HibernateUtil.setSessionFactory(config.buildSessionFactory());
   
    // uncomment the following if you want to launch a the dbmanager gui (while debugging through this class probably)
/*    Runnable r = new Runnable() {
      @Override
      public void run() {
View Full Code Here

TOP

Related Classes of org.hibernate.cfg.Configuration$ObjectNameNormalizerImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.