Package org.hibernate.cfg

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


public class TestDailyStatHsqldbSchema 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(DailyStat.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 TestWeeklyStatHsqldbSchema 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(WeeklyStat.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 void start() throws Exception {

        // Configure Hibernate using the hibernate.cfg.xml.
        String hbnCfgPath = Application.lookup().getBaseCfgDirectory() + File.separator + "hibernate.cfg.xml";
        hbmConfig = new Configuration().configure(new File(hbnCfgPath));

        // Infer the underlying database name.
        databaseName = inferDatabaseName();
        log.info("The underlying database is: " + databaseName);
View Full Code Here

    private static final SessionFactory sessionFactory = buildSessionFactory();

    private static SessionFactory buildSessionFactory() {
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            return new Configuration().configure().buildSessionFactory();
        } catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
View Full Code Here

  /**
   * @param configurationResourceName
   *            The Infinispan configuration resource to use to try booting OGM
   */
  private void tryBoot(String configurationResourceName) {
    Configuration cfg = new OgmConfiguration();
    cfg.setProperty( OgmProperties.DATASTORE_PROVIDER, "infinispan" );
    cfg.setProperty( InfinispanProperties.CONFIGURATION_RESOURCE_NAME, configurationResourceName );
    SessionFactory sessionFactory = cfg.buildSessionFactory();
    if ( sessionFactory != null ) {
      try {
        // trigger service initialization, and also verifies it actually uses Infinispan:
        InfinispanTestHelper.getProvider( sessionFactory );
      }
View Full Code Here

  public SessionFactoryProvider(@Context final ResourceConfig rc) {
    super(SessionFactory.class, createSessionFactory(rc));
  }
 
  private static SessionFactory createSessionFactory(final ResourceConfig rc) {
    Configuration configuration = new Configuration().configure();
    String url = configuration.getProperty("hibernate.connection.url");
    url = url.replace("//localhost:3306/", "//" + rc.getProperty("dbhost") + ":" + rc.getProperty("dbport") + "/");
    configuration.setProperty("hibernate.connection.url", url);
    configuration.addAnnotatedClass(World.class);
    configuration.addAnnotatedClass(Fortune.class);
    ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder().applySettings(configuration.getProperties());
    return configuration.buildSessionFactory(serviceRegistryBuilder.buildServiceRegistry());
  }
View Full Code Here

    }
  }

  protected SessionFactory buildSessionFactory() {
    Class<?>[] classes = getConfiguredEntityTypes();
    Configuration configuration = createConfiguration( classes );

    return configuration.buildSessionFactory();
  }
View Full Code Here

        }
    }
   
    private static SessionFactory createSessionFactory() {
        try {
            Configuration configuration = configuration();
            String url = configuration.getProperty(AvailableSettings.URL);
            configuration.setProperty(AvailableSettings.URL, url.replace("{db-host}", "localhost"));
            configuration.setProperty(AvailableSettings.DIALECT, MySQLDialect.class.getName());
            configuration.setProperty(AvailableSettings.USE_QUERY_CACHE, "false");
            configuration.setProperty(AvailableSettings.SHOW_SQL, "false");
            configuration.setProperty(AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS, "thread");
            configuration.addAnnotatedClass(World.class);
            StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
            return configuration.buildSessionFactory(serviceRegistryBuilder.build());
        } catch (RuntimeException ex) {
            LOGGER.error("Failed to create session factory");
            throw ex;
        }
    }
View Full Code Here

        }
    }
   
    private static Configuration configuration() {
        boolean jndi = Boolean.parseBoolean(System.getProperty("jndi", "true"));
        Configuration configuration = new Configuration();
        // We're always going to use the -local config now since there were previous
        // problems with the jndi config.
        /*
        if (jndi) {
            configuration.configure("/hibernate-jndi.cfg.xml");
        } else {
            configuration.configure("/hibernate-local.cfg.xml");
        }
        */
        configuration.configure("/hibernate-local.cfg.xml");
        return configuration;
    }
View Full Code Here

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

  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 );
      }

      BasicServiceRegistryImpl serviceRegistry = createServiceRegistry( cfg.getProperties() );
      try {
        new SchemaValidator( serviceRegistry, cfg ).validate();
      }
      finally {
        serviceRegistry.destroy();
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.