Package org.hibernate.cfg

Examples of org.hibernate.cfg.Configuration$CacheHolder


  public static volatile String PASS = "";

  public static final Dialect DIALECT = new H2Dialect();

  public static Configuration buildBaseConfiguration() {
    return new Configuration()
        .setProperty( Environment.DRIVER, DRIVER )
        .setProperty( Environment.URL, URL )
        .setProperty( Environment.USER, USER )
        .setProperty( Environment.PASS, PASS )
        .setProperty( Environment.DIALECT, DIALECT.getClass().getName() );
View Full Code Here


    return (MetadataImplementor) sources.getMetadataBuilder( serviceRegistry ).build();
  }

  // TODO: is this still needed?
  protected Configuration buildConfiguration() {
    Configuration cfg = constructAndConfigureConfiguration();
    afterConstructAndConfigureConfiguration( cfg );
    return cfg;
  }
View Full Code Here

    afterConstructAndConfigureConfiguration( cfg );
    return cfg;
  }

  protected Configuration constructAndConfigureConfiguration() {
    Configuration cfg = constructConfiguration();
    configure( cfg );
    return cfg;
  }
View Full Code Here

    applyCacheSettings( cfg );
    afterConfigurationBuilt( cfg );
  }

  protected Configuration constructConfiguration() {
    Configuration configuration = new Configuration()
        .setProperty(Environment.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName()  );
    configuration.setProperty( AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
    if ( createSchema() ) {
      configuration.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
      final String secondSchemaName = createSecondSchema();
      if ( StringHelper.isNotEmpty( secondSchemaName ) ) {
        if ( !( getDialect() instanceof H2Dialect ) ) {
          throw new UnsupportedOperationException( "Only H2 dialect supports creation of second schema." );
        }
        Helper.createH2Schema( secondSchemaName, configuration );
      }
    }
    configuration.setProperty( Environment.DIALECT, getDialect().getClass().getName() );
    return configuration;
  }
View Full Code Here

   
  }

  public static void main(String[] args) {
    try {
      Configuration cfg = new Configuration();

      boolean script = true;
      boolean drop = false;
      boolean create = false;
      boolean halt = false;
      boolean export = true;
      String outFile = null;
      String importFile = "/import.sql";
      String propFile = null;
      boolean format = false;
      String delim = null;

      for ( int i = 0; i < args.length; i++ ) {
        if ( args[i].startsWith( "--" ) ) {
          if ( args[i].equals( "--quiet" ) ) {
            script = false;
          }
          else if ( args[i].equals( "--drop" ) ) {
            drop = true;
          }
          else if ( args[i].equals( "--create" ) ) {
            create = true;
          }
          else if ( args[i].equals( "--haltonerror" ) ) {
            halt = true;
          }
          else if ( args[i].equals( "--text" ) ) {
            export = false;
          }
          else if ( args[i].startsWith( "--output=" ) ) {
            outFile = args[i].substring( 9 );
          }
          else if ( args[i].startsWith( "--import=" ) ) {
            importFile = args[i].substring( 9 );
          }
          else if ( args[i].startsWith( "--properties=" ) ) {
            propFile = args[i].substring( 13 );
          }
          else if ( args[i].equals( "--format" ) ) {
            format = true;
          }
          else if ( args[i].startsWith( "--delimiter=" ) ) {
            delim = args[i].substring( 12 );
          }
          else if ( args[i].startsWith( "--config=" ) ) {
            cfg.configure( args[i].substring( 9 ) );
          }
          else if ( args[i].startsWith( "--naming=" ) ) {
            cfg.setNamingStrategy(
                ( NamingStrategy ) ReflectHelper.classForName( args[i].substring( 9 ) )
                    .newInstance()
            );
          }
        }
        else {
          String filename = args[i];
          if ( filename.endsWith( ".jar" ) ) {
            cfg.addJar( new File( filename ) );
          }
          else {
            cfg.addFile( filename );
          }
        }

      }

      if ( propFile != null ) {
        Properties props = new Properties();
        props.putAll( cfg.getProperties() );
        props.load( new FileInputStream( propFile ) );
        cfg.setProperties( props );
      }

      SchemaExport se = new SchemaExport( cfg )
          .setHaltOnError( halt )
          .setOutputFile( outFile )
View Full Code Here

    }
  }

  protected final Configuration buildConfiguration() {

    Configuration cfg = new Configuration().setProperties( buildProperties() );


    String[] mappingFiles = PropertiesHelper.toStringArray( mapResources, " ,\n\t\r\f" );
    for ( int i = 0; i < mappingFiles.length; i++ ) {
      cfg.addResource( mappingFiles[i] );
    }

    if ( customListeners != null && !customListeners.isEmpty() ) {
      Iterator entries = customListeners.entrySet().iterator();
      while ( entries.hasNext() ) {
        final Map.Entry entry = ( Map.Entry ) entries.next();
        final String type = ( String ) entry.getKey();
        final Object value = entry.getValue();
        if ( value != null ) {
          if ( String.class.isAssignableFrom( value.getClass() ) ) {
            // Its the listener class name
            cfg.setListener( type, ( ( String ) value ) );
          }
          else {
            // Its the listener instance (or better be)
            cfg.setListener( type, value );
          }
        }
      }
    }
View Full Code Here

   */
  public void execute() throws BuildException {
    try {
      log("Running Hibernate Core SchemaUpdate.");
      log("This is an Ant task supporting only mapping files, if you want to use annotations see http://tools.hibernate.org.");
      Configuration cfg = getConfiguration();
      getSchemaUpdate(cfg).execute(!quiet, !text);
    }
    catch (HibernateException e) {
      throw new BuildException("Schema text failed: " + e.getMessage(), e);
    }
View Full Code Here

    return ArrayHelper.toStringArray(files);
  }

  private Configuration getConfiguration() throws Exception {
    Configuration cfg = new Configuration();
    if (namingStrategy!=null) {
      cfg.setNamingStrategy(
          (NamingStrategy) ReflectHelper.classForName(namingStrategy).newInstance()
        );
    }
    if (configurationFile!=null) {
      cfg.configure( configurationFile );
    }

    String[] files = getFiles();
    for (int i = 0; i < files.length; i++) {
      String filename = files[i];
      if ( filename.endsWith(".jar") ) {
        cfg.addJar( new File(filename) );
      }
      else {
        cfg.addFile(filename);
      }
    }
    return cfg;
  }
View Full Code Here

    );
  }

  public static void main(String[] args) {
    try {
      Configuration cfg = new Configuration();

      String propFile = null;

      for ( int i = 0; i < args.length; i++ ) {
        if ( args[i].startsWith( "--" ) ) {
          if ( args[i].startsWith( "--properties=" ) ) {
            propFile = args[i].substring( 13 );
          }
          else if ( args[i].startsWith( "--config=" ) ) {
            cfg.configure( args[i].substring( 9 ) );
          }
          else if ( args[i].startsWith( "--naming=" ) ) {
            cfg.setNamingStrategy(
                ( NamingStrategy ) ReflectHelper.classForName( args[i].substring( 9 ) ).newInstance()
            );
          }
        }
        else {
          cfg.addFile( args[i] );
        }

      }

      if ( propFile != null ) {
        Properties props = new Properties();
        props.putAll( cfg.getProperties() );
        props.load( new FileInputStream( propFile ) );
        cfg.setProperties( props );
      }

      new SchemaValidator( cfg ).validate();
    }
    catch ( Exception e ) {
View Full Code Here

  /**
   * Execute the task
   */
  public void execute() throws BuildException {
    try {
      Configuration cfg = getConfiguration();
      getSchemaValidator(cfg).validate();
    }
    catch (HibernateException e) {
      throw new BuildException("Schema text failed: " + e.getMessage(), e);
    }
View Full Code Here

TOP

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

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.