Package org.hibernate.cfg

Examples of org.hibernate.cfg.Configuration$MappingsImpl$TableColumnNameBinding


    // We need custom ClassloaderService, which is able to locate our UserTransactionJtaPlatform class from tccl.
    // Default ClassLoaderServiceImpl is bootstrapped with no-arg constructor, so it uses only Hibernate Classloader
    // TODO: Remove once https://issues.jboss.org/browse/HIBERNATE-137 will be fixed (likely whole class can be removed)
    protected SessionFactory buildSessionFactory() {
        Configuration conf = getHibernateConfiguration();

        BootstrapServiceRegistry bootstrapRegistry = createHibernateBootstrapServiceRegistry();

        final ServiceRegistry serviceRegistry = new ServiceRegistryBuilder(bootstrapRegistry).applySettings(
                conf.getProperties()).buildServiceRegistry();
        conf.setSessionFactoryObserver(new SessionFactoryObserver() {
            @Override
            public void sessionFactoryCreated(SessionFactory factory) {
            }

            @Override
            public void sessionFactoryClosed(SessionFactory factory) {
                ((StandardServiceRegistryImpl) serviceRegistry).destroy();
            }
        });
        return conf.buildSessionFactory(serviceRegistry);
    }
View Full Code Here


    super.doStart();
  }

  private void exportGeneralSettings() {
    Cfg2HbmTool c2h = getCfg2HbmTool();
    Configuration cfg = getConfiguration();
    if(c2h.isImportData(cfg) && (c2h.isNamedQueries(cfg)) && (c2h.isNamedSQLQueries(cfg)) && (c2h.isFilterDefinitions(cfg))) {
      TemplateProducer producer = new TemplateProducer(getTemplateHelper(),getArtifactCollector());
      producer.produce(new HashMap(), "hbm/generalhbm.hbm.ftl", new File(getOutputDirectory(),"GeneralHbmSettings.hbm.xml"), getTemplateName(), "General Settings");
    }
  }
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

   */
  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

    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

    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

    }
  }

  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

TOP

Related Classes of org.hibernate.cfg.Configuration$MappingsImpl$TableColumnNameBinding

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.