Package org.hibernate.cfg

Examples of org.hibernate.cfg.Settings


      testee.setConfigurationElements(config);
      testee.start();
     
      SessionFactory factory = testee.getInstance();
      assertTrue(factory instanceof SessionFactoryImplementor);
      Settings settings = ((SessionFactoryImplementor) factory).getSettings();
      assertTrue(settings.getTransactionFactory() instanceof JTATransactionFactory);
      assertTrue(settings.isSecondLevelCacheEnabled());
     
      assertTrue(settings.isFlushBeforeCompletionEnabled());
      assertTrue(settings.isAutoCloseSessionEnabled());
     
      Properties props = testee.getConfigurationProperties();
      assertEquals(HashtableCacheProvider.class.getName(), props.getProperty(Environment.CACHE_PROVIDER));
      assertEquals("after_statement", props.getProperty("hibernate.connection.release_mode"));
      // Disabled, as use of JTA causes hibernate to ignore hibernate.connection.release_mode=after_statement
View Full Code Here


      assertEquals(MockListenerInjector.class.getName(), testee.getListenerInjector());
     
      // Where we can, validate stuff exposed by hibernate Settings
      SessionFactory factory = testee.getInstance();
      assertTrue(factory instanceof SessionFactoryImplementor);
      Settings settings = ((SessionFactoryImplementor) factory).getSettings();
     
//      assertEquals(TestableHibernate.class.getSimpleName() + testCount, settings.getSessionFactoryName());
      assertEquals(HSQLDialect.class.getName(), testee.getDialect());
      assertTrue(settings.getDialect() instanceof HSQLDialect);
      assertTrue(settings.getTransactionFactory() instanceof JTATransactionFactory);
      assertTrue(settings.getTransactionManagerLookup() instanceof TransactionManagerLookupImpl);
      assertTrue(settings.getRegionFactory() instanceof MockRegionFactory);
      assertEquals("aprefix", settings.getCacheRegionPrefix());
      assertTrue(settings.isMinimalPutsEnabled());
      assertTrue(settings.isSecondLevelCacheEnabled());
      assertTrue(settings.isQueryCacheEnabled());
      assertTrue(settings.isStructuredCacheEntriesEnabled());
      assertEquals("schema", settings.getDefaultSchemaName());
      assertEquals("catalog", settings.getDefaultCatalogName());
      assertEquals(Integer.valueOf(9), settings.getJdbcFetchSize());
      assertTrue(settings.isJdbcBatchVersionedData());
      assertEquals(Integer.valueOf(13), settings.getMaximumFetchDepth());
      assertTrue(settings.isScrollableResultSetsEnabled());
      assertTrue(settings.isCommentsEnabled());
      @SuppressWarnings("unchecked")
      Map substitutions = settings.getQuerySubstitutions();
      assertNotNull(substitutions);
      assertEquals(1, substitutions.size());
      assertEquals("value", substitutions.get("key"));
      assertTrue(settings.getSqlStatementLogger().isLogToStdout());
      assertTrue(settings.isGetGeneratedKeysEnabled());
      assertTrue(settings.isStatisticsEnabled());
     
      // For stuff not available via Settings, second best is to check the properties exposed by Hibernate object
      Properties props = testee.getConfigurationProperties();
      assertEquals(JTATransactionFactory.DEFAULT_USER_TRANSACTION_NAME, props.getProperty(Environment.USER_TRANSACTION));
      assertEquals(MockCacheProvider.class.getName(), props.getProperty(Environment.CACHE_PROVIDER));
View Full Code Here

  }

  protected String generateSubquery(PersistentClass model, Mapping mapping) {

    Dialect dialect = getFactory().getDialect();
    Settings settings = getFactory().getSettings();
   
    if ( !model.hasSubclasses() ) {
      return model.getTable().getQualifiedName(
          dialect,
          settings.getDefaultCatalogName(),
          settings.getDefaultSchemaName()
        );
    }

    HashSet columns = new HashSet();
    Iterator titer = model.getSubclassTableClosureIterator();
    while ( titer.hasNext() ) {
      Table table = (Table) titer.next();
      if ( !table.isAbstractUnionTable() ) {
        Iterator citer = table.getColumnIterator();
        while ( citer.hasNext() ) columns.add( citer.next() );
      }
    }

    StringBuffer buf = new StringBuffer()
      .append("( ");

    Iterator siter = new JoinedIterator(
      new SingletonIterator(model),
      model.getSubclassIterator()
    );

    while ( siter.hasNext() ) {
      PersistentClass clazz = (PersistentClass) siter.next();
      Table table = clazz.getTable();
      if ( !table.isAbstractUnionTable() ) {
        //TODO: move to .sql package!!
        buf.append("select ");
        Iterator citer = columns.iterator();
        while ( citer.hasNext() ) {
          Column col = (Column) citer.next();
          if ( !table.containsColumn(col) ) {
            int sqlType = col.getSqlTypeCode(mapping);
            buf.append( dialect.getSelectClauseNullString(sqlType) )
              .append(" as ");
          }
          buf.append( col.getName() );
          buf.append(", ");
        }
        buf.append( clazz.getSubclassId() )
          .append(" as clazz_");
        buf.append(" from ")
          .append( table.getQualifiedName(
              dialect,
              settings.getDefaultCatalogName(),
              settings.getDefaultSchemaName()
          ) );
        buf.append(" union ");
        if ( dialect.supportsUnionAll() ) {
          buf.append("all ");
        }
View Full Code Here

        this.cfg = cfg;

        dialect = cfg.buildSettings().getDialect(); // TODO: get it from somewhere "cached".
       
        Settings settings = cfg.buildSettings();

        String defaultCatalog = settings.getDefaultCatalogName();

        String defaultSchema = settings.getDefaultSchemaName();     
       

        if (defaultSchema == null) {
            defaultSchema = DEFAULT_NO_SCHEMA_NAME;
        }
View Full Code Here

  }

  protected String generateSubquery(PersistentClass model, Mapping mapping) {

    Dialect dialect = getFactory().getDialect();
    Settings settings = getFactory().getSettings();
   
    if ( !model.hasSubclasses() ) {
      return model.getTable().getQualifiedName(
          dialect,
          settings.getDefaultCatalogName(),
          settings.getDefaultSchemaName()
        );
    }

    HashSet columns = new LinkedHashSet();
    Iterator titer = model.getSubclassTableClosureIterator();
    while ( titer.hasNext() ) {
      Table table = (Table) titer.next();
      if ( !table.isAbstractUnionTable() ) {
        Iterator citer = table.getColumnIterator();
        while ( citer.hasNext() ) columns.add( citer.next() );
      }
    }

    StringBuffer buf = new StringBuffer()
      .append("( ");

    Iterator siter = new JoinedIterator(
      new SingletonIterator(model),
      model.getSubclassIterator()
    );

    while ( siter.hasNext() ) {
      PersistentClass clazz = (PersistentClass) siter.next();
      Table table = clazz.getTable();
      if ( !table.isAbstractUnionTable() ) {
        //TODO: move to .sql package!!
        buf.append("select ");
        Iterator citer = columns.iterator();
        while ( citer.hasNext() ) {
          Column col = (Column) citer.next();
          if ( !table.containsColumn(col) ) {
            int sqlType = col.getSqlTypeCode(mapping);
            buf.append( dialect.getSelectClauseNullString(sqlType) )
              .append(" as ");
          }
          buf.append( col.getName() );
          buf.append(", ");
        }
        buf.append( clazz.getSubclassId() )
          .append(" as clazz_");
        buf.append(" from ")
          .append( table.getQualifiedName(
              dialect,
              settings.getDefaultCatalogName(),
              settings.getDefaultSchemaName()
          ) );
        buf.append(" union ");
        if ( dialect.supportsUnionAll() ) {
          buf.append("all ");
        }
View Full Code Here

  }

  protected String generateSubquery(PersistentClass model, Mapping mapping) {

    Dialect dialect = getFactory().getDialect();
    Settings settings = getFactory().getSettings();
   
    if ( !model.hasSubclasses() ) {
      return model.getTable().getQualifiedName(
          dialect,
          settings.getDefaultCatalogName(),
          settings.getDefaultSchemaName()
        );
    }

    HashSet columns = new LinkedHashSet();
    Iterator titer = model.getSubclassTableClosureIterator();
    while ( titer.hasNext() ) {
      Table table = (Table) titer.next();
      if ( !table.isAbstractUnionTable() ) {
        Iterator citer = table.getColumnIterator();
        while ( citer.hasNext() ) columns.add( citer.next() );
      }
    }

    StringBuilder buf = new StringBuilder()
      .append("( ");

    Iterator siter = new JoinedIterator(
      new SingletonIterator(model),
      model.getSubclassIterator()
    );

    while ( siter.hasNext() ) {
      PersistentClass clazz = (PersistentClass) siter.next();
      Table table = clazz.getTable();
      if ( !table.isAbstractUnionTable() ) {
        //TODO: move to .sql package!!
        buf.append("select ");
        Iterator citer = columns.iterator();
        while ( citer.hasNext() ) {
          Column col = (Column) citer.next();
          if ( !table.containsColumn(col) ) {
            int sqlType = col.getSqlTypeCode(mapping);
            buf.append( dialect.getSelectClauseNullString(sqlType) )
              .append(" as ");
          }
          buf.append( col.getQuotedName(dialect) );
          buf.append(", ");
        }
        buf.append( clazz.getSubclassId() )
          .append(" as clazz_");
        buf.append(" from ")
          .append( table.getQualifiedName(
              dialect,
              settings.getDefaultCatalogName(),
              settings.getDefaultSchemaName()
          ) );
        buf.append(" union ");
        if ( dialect.supportsUnionAll() ) {
          buf.append("all ");
        }
View Full Code Here

    private List<SessionEventListener> listeners;

    SessionBuilderImpl(SessionFactoryImpl sessionFactory) {
      this.sessionFactory = sessionFactory;
      this.sessionOwner = null;
      final Settings settings = sessionFactory.settings;

      // set up default builder values...
      this.interceptor = sessionFactory.getInterceptor();
      this.connectionReleaseMode = settings.getConnectionReleaseMode();
      this.autoClose = settings.isAutoCloseSessionEnabled();
      this.flushBeforeCompletion = settings.isFlushBeforeCompletionEnabled();

      if ( sessionFactory.getCurrentTenantIdentifierResolver() != null ) {
        tenantIdentifier = sessionFactory.getCurrentTenantIdentifierResolver().resolveCurrentTenantIdentifier();
      }

      listeners = settings.getBaselineSessionEventsListenerBuilder().buildBaselineList();
    }
View Full Code Here

  }

  protected String generateSubquery(PersistentClass model, Mapping mapping) {

    Dialect dialect = getFactory().getDialect();
    Settings settings = getFactory().getSettings();
   
    if ( !model.hasSubclasses() ) {
      return model.getTable().getQualifiedName(
          dialect,
          settings.getDefaultCatalogName(),
          settings.getDefaultSchemaName()
        );
    }

    HashSet columns = new HashSet();
    Iterator titer = model.getSubclassTableClosureIterator();
    while ( titer.hasNext() ) {
      Table table = (Table) titer.next();
      if ( !table.isAbstractUnionTable() ) {
        Iterator citer = table.getColumnIterator();
        while ( citer.hasNext() ) columns.add( citer.next() );
      }
    }

    StringBuffer buf = new StringBuffer()
      .append("( ");

    Iterator siter = new JoinedIterator(
      new SingletonIterator(model),
      model.getSubclassIterator()
    );

    while ( siter.hasNext() ) {
      PersistentClass clazz = (PersistentClass) siter.next();
      Table table = clazz.getTable();
      if ( !table.isAbstractUnionTable() ) {
        //TODO: move to .sql package!!
        buf.append("select ");
        Iterator citer = columns.iterator();
        while ( citer.hasNext() ) {
          Column col = (Column) citer.next();
          if ( !table.containsColumn(col) ) {
            int sqlType = col.getSqlTypeCode(mapping);
            buf.append( dialect.getSelectClauseNullString(sqlType) )
              .append(" as ");
          }
          buf.append( col.getName() );
          buf.append(", ");
        }
        buf.append( clazz.getSubclassId() )
          .append(" as clazz_");
        buf.append(" from ")
          .append( table.getQualifiedName(
              dialect,
              settings.getDefaultCatalogName(),
              settings.getDefaultSchemaName()
          ) );
        buf.append(" union ");
        if ( dialect.supportsUnionAll() ) {
          buf.append("all ");
        }
View Full Code Here

  }

  protected String generateSubquery(PersistentClass model, Mapping mapping) {

    Dialect dialect = getFactory().getDialect();
    Settings settings = getFactory().getSettings();
   
    if ( !model.hasSubclasses() ) {
      return model.getTable().getQualifiedName(
          dialect,
          settings.getDefaultCatalogName(),
          settings.getDefaultSchemaName()
        );
    }

    HashSet columns = new HashSet();
    Iterator titer = model.getSubclassTableClosureIterator();
    while ( titer.hasNext() ) {
      Table table = (Table) titer.next();
      if ( !table.isAbstractUnionTable() ) {
        Iterator citer = table.getColumnIterator();
        while ( citer.hasNext() ) columns.add( citer.next() );
      }
    }

    StringBuffer buf = new StringBuffer()
      .append("( ");

    Iterator siter = new JoinedIterator(
      new SingletonIterator(model),
      model.getSubclassIterator()
    );

    while ( siter.hasNext() ) {
      PersistentClass clazz = (PersistentClass) siter.next();
      Table table = clazz.getTable();
      if ( !table.isAbstractUnionTable() ) {
        //TODO: move to .sql package!!
        buf.append("select ");
        Iterator citer = columns.iterator();
        while ( citer.hasNext() ) {
          Column col = (Column) citer.next();
          if ( !table.containsColumn(col) ) {
            int sqlType = col.getSqlTypeCode(mapping);
            buf.append( dialect.getSelectClauseNullString(sqlType) )
              .append(" as ");
          }
          buf.append( col.getName() );
          buf.append(", ");
        }
        buf.append( clazz.getSubclassId() )
          .append(" as clazz_");
        buf.append(" from ")
          .append( table.getQualifiedName(
              dialect,
              settings.getDefaultCatalogName(),
              settings.getDefaultSchemaName()
          ) );
        buf.append(" union ");
        if ( dialect.supportsUnionAll() ) {
          buf.append("all ");
        }
View Full Code Here

     *
     * @param sessionFactory
     * @return currently used <code>HazelcastInstance</code> or null if an error occurs.
     */
    public static HazelcastInstance getHazelcastInstance(final SessionFactoryImplementor sessionFactory) {
        final Settings settings = sessionFactory.getSettings();
        final RegionFactory rf = settings.getRegionFactory();
        if (rf == null) {
            logger.severe("Hibernate 2nd level cache has not been enabled!");
            return null;
        }
        if (rf instanceof AbstractHazelcastCacheRegionFactory) {
View Full Code Here

TOP

Related Classes of org.hibernate.cfg.Settings

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.