Search in sources :

Example 1 with Configuration

use of org.hibernate.cfg.Configuration in project dropwizard by dropwizard.

the class SessionFactoryFactory method buildSessionFactory.

private SessionFactory buildSessionFactory(HibernateBundle<?> bundle, PooledDataSourceFactory dbConfig, ConnectionProvider connectionProvider, Map<String, String> properties, List<Class<?>> entities) {
    final Configuration configuration = new Configuration();
    configuration.setProperty(AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS, "managed");
    configuration.setProperty(AvailableSettings.USE_SQL_COMMENTS, Boolean.toString(dbConfig.isAutoCommentsEnabled()));
    configuration.setProperty(AvailableSettings.USE_GET_GENERATED_KEYS, "true");
    configuration.setProperty(AvailableSettings.GENERATE_STATISTICS, "true");
    configuration.setProperty(AvailableSettings.USE_REFLECTION_OPTIMIZER, "true");
    configuration.setProperty(AvailableSettings.ORDER_UPDATES, "true");
    configuration.setProperty(AvailableSettings.ORDER_INSERTS, "true");
    configuration.setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
    configuration.setProperty("jadira.usertype.autoRegisterUserTypes", "true");
    for (Map.Entry<String, String> property : properties.entrySet()) {
        configuration.setProperty(property.getKey(), property.getValue());
    }
    addAnnotatedClasses(configuration, entities);
    bundle.configure(configuration);
    final ServiceRegistry registry = new StandardServiceRegistryBuilder().addService(ConnectionProvider.class, connectionProvider).applySettings(configuration.getProperties()).build();
    configure(configuration, registry);
    return configuration.buildSessionFactory(registry);
}
Also used : Configuration(org.hibernate.cfg.Configuration) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) ServiceRegistry(org.hibernate.service.ServiceRegistry) Map(java.util.Map)

Example 2 with Configuration

use of org.hibernate.cfg.Configuration in project onebusaway-gtfs-modules by OneBusAway.

the class LongRouteDescriptionTest method setup.

@BeforeClass
public static void setup() throws IOException {
    Configuration config = new Configuration();
    config = config.configure("org/onebusaway/gtfs/hibernate-configuration.xml");
    _sessionFactory = config.buildSessionFactory();
    _dao = new HibernateGtfsRelationalDaoImpl(_sessionFactory);
    GtfsReader reader = new GtfsReader();
    reader.setInputLocation(new File("src/test/resources/org/onebusaway/gtfs/caltrain-long-route.zip"));
    reader.setEntityStore(_dao);
    reader.setDefaultAgencyId(_agencyId);
    List<Class<?>> entityClasses = reader.getEntityClasses();
    entityClasses.clear();
    entityClasses.add(Agency.class);
    entityClasses.add(Route.class);
    reader.run();
}
Also used : GtfsReader(org.onebusaway.gtfs.serialization.GtfsReader) Configuration(org.hibernate.cfg.Configuration) AfterClass(org.junit.AfterClass) BeforeClass(org.junit.BeforeClass) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 3 with Configuration

use of org.hibernate.cfg.Configuration in project onebusaway-gtfs-modules by OneBusAway.

the class GtfsMappingTest method setup.

@Before
public void setup() throws IOException {
    Configuration config = new Configuration();
    config = config.configure("org/onebusaway/gtfs/hibernate-configuration.xml");
    _sessionFactory = config.buildSessionFactory();
    _dao = new HibernateGtfsRelationalDaoImpl(_sessionFactory);
    _dao.open();
    _reader = new GtfsReader();
    _reader.setEntityStore(_dao);
}
Also used : GtfsReader(org.onebusaway.gtfs.serialization.GtfsReader) Configuration(org.hibernate.cfg.Configuration) Before(org.junit.Before)

Example 4 with Configuration

use of org.hibernate.cfg.Configuration in project onebusaway-gtfs-modules by OneBusAway.

the class HibernateGtfsRelationalImplBartTest method setup.

@BeforeClass
public static void setup() throws IOException {
    Configuration config = new Configuration();
    config = config.configure("org/onebusaway/gtfs/hibernate-configuration.xml");
    _sessionFactory = config.buildSessionFactory();
    _dao = new HibernateGtfsRelationalDaoImpl(_sessionFactory);
    GtfsReader reader = new GtfsReader();
    reader.setInputLocation(new File("src/test/resources/org/onebusaway/gtfs/bart.zip"));
    reader.setEntityStore(_dao);
    reader.setDefaultAgencyId(_agencyId);
    reader.run();
}
Also used : GtfsReader(org.onebusaway.gtfs.serialization.GtfsReader) Configuration(org.hibernate.cfg.Configuration) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 5 with Configuration

use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.

the class BaseCoreFunctionalTestCase method buildConfiguration.

protected Configuration buildConfiguration() {
    Configuration cfg = constructAndConfigureConfiguration();
    afterConstructAndConfigureConfiguration(cfg);
    return cfg;
}
Also used : Configuration(org.hibernate.cfg.Configuration)

Aggregations

Configuration (org.hibernate.cfg.Configuration)179 Test (org.junit.Test)66 Session (org.hibernate.Session)37 SessionFactory (org.hibernate.SessionFactory)34 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)27 BeforeClass (org.junit.BeforeClass)19 Before (org.junit.Before)18 ServiceRegistry (org.hibernate.service.ServiceRegistry)14 File (java.io.File)13 Properties (java.util.Properties)11 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)9 EncapsulatedCompositeIdResultSetProcessorTest (org.hibernate.test.loadplans.process.EncapsulatedCompositeIdResultSetProcessorTest)8 HibernateException (org.hibernate.HibernateException)7 MappingException (org.hibernate.MappingException)7 Transaction (org.hibernate.Transaction)7 URL (java.net.URL)6 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)6 TestForIssue (org.hibernate.testing.TestForIssue)6 EntityTuplizer (org.hibernate.tuple.entity.EntityTuplizer)6 BigDecimal (java.math.BigDecimal)5