Package org.hibernate.cfg

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


    return (BasicServiceRegistryImpl) new ServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry();
  }

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

      boolean script = true;
      // If true then execute db updates, otherwise just generate and display updates
      boolean doUpdate = true;
      String propFile = null;

      for ( int i = 0; i < args.length; i++ ) {
        if ( args[i].startsWith( "--" ) ) {
          if ( args[i].equals( "--quiet" ) ) {
            script = false;
          }
          else 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( "--text" ) ) {
            doUpdate = false;
          }
          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 );
      }

      BasicServiceRegistryImpl serviceRegistry = createServiceRegistry( cfg.getProperties() );
      try {
        new SchemaUpdate( serviceRegistry, cfg ).execute( script, doUpdate );
      }
      finally {
        serviceRegistry.destroy();
View Full Code Here


            return;
        }

        try {

            setCfg(new Configuration());

            if (recreateSchema()) {
                cfg.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
            }
View Full Code Here

 
  public static List<process> viewRecord(String s[]){ 
   
   
   
    SessionFactory sf=new Configuration().configure().buildSessionFactory();
    Session session=sf.openSession();
   
    Criteria c1=session.createCriteria(process.class);
    // c1.add(Restrictions.and(Restrictions.eq("id", new Integer(0)),Restrictions.like("username","vipul")));
          //      c1.addOrder(Order.desc("id"));
View Full Code Here

            }
        };
        HibernateSessionSource source = new HibernateSessionSourceImpl(log, Arrays
                .asList(configurer));

        Configuration config = source.getConfiguration();
        assertNotNull(config);
        assertEquals("bar", config.getProperty("foo"));

        // configuration should be immutable
        try
        {
            config.setProperty("hibernate.dialect", "foo");
            fail("did not throw");
        }
        catch (UnsupportedOperationException e)
        {
            assertTrue(e.getMessage().contains("immutable"));
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 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

   
  }

  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

    exceptions = new ArrayList();
  }

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

      boolean script = true;
      // If true then execute db updates, otherwise just generate and display updates
      boolean doUpdate = true;
      String propFile = null;

      for ( int i = 0; i < args.length; i++ ) {
        if ( args[i].startsWith( "--" ) ) {
          if ( args[i].equals( "--quiet" ) ) {
            script = false;
          }
          else 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( "--text" ) ) {
            doUpdate = false;
          }
          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 SchemaUpdate( cfg ).execute( script, doUpdate );
    }
    catch ( Exception e ) {
View Full Code Here

     */
    public void execute() throws BuildException {
        try {
            log("Running Hibernate Core SchemaUpdate.");
            log("###CILEA HACK to support Hibernate annotation");
            Configuration cfg = getConfiguration();
            getSchemaUpdate(cfg).execute(!quiet, !text);
        }
        catch (HibernateException e) {
            throw new BuildException("Schema text failed: " + e.getMessage(), e);
        }
View Full Code Here

    super.cleanUpContext();
  }

  protected void doStart() {

    final Configuration configuration = getConfiguration();
    if (schemaUpdate) {
      SchemaUpdate update = new SchemaUpdate(configuration);
     
      // classic schemaupdate execution, will work with all releases
      if(outputFileName == null && delimiter == null && haltOnError && format)
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.