Search in sources :

Example 46 with Configuration

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

the class BasicIntegratorTest method testNoAudited.

/**
	 * Tests that nothing crazy happens if the hibernate-envers jar happens
	 * to be on the classpath but we have no audited entities
	 */
@Test
@TestForIssue(jiraKey = "HHH-9675")
public void testNoAudited() {
    new Configuration().buildSessionFactory().close();
    new Configuration().addAnnotatedClass(SimpleNonAuditedEntity.class).buildSessionFactory().close();
}
Also used : Configuration(org.hibernate.cfg.Configuration) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 47 with Configuration

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

the class CacheKeySerializationTest method getSessionFactory.

private SessionFactoryImplementor getSessionFactory(String cacheKeysFactory) {
    Configuration configuration = new Configuration().setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true").setProperty(Environment.CACHE_REGION_FACTORY, TestInfinispanRegionFactory.class.getName()).setProperty(Environment.DEFAULT_CACHE_CONCURRENCY_STRATEGY, "transactional").setProperty(AvailableSettings.SHARED_CACHE_MODE, "ALL").setProperty(Environment.HBM2DDL_AUTO, "create-drop");
    if (cacheKeysFactory != null) {
        configuration.setProperty(Environment.CACHE_KEYS_FACTORY, cacheKeysFactory);
    }
    configuration.addAnnotatedClass(WithSimpleId.class);
    configuration.addAnnotatedClass(WithEmbeddedId.class);
    return (SessionFactoryImplementor) configuration.buildSessionFactory();
}
Also used : Configuration(org.hibernate.cfg.Configuration) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor)

Example 48 with Configuration

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

the class CacheKeysFactoryTest method getSessionFactory.

private SessionFactory getSessionFactory(String cacheKeysFactory) {
    Configuration configuration = new Configuration().setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true").setProperty(Environment.CACHE_REGION_FACTORY, TestInfinispanRegionFactory.class.getName()).setProperty(Environment.DEFAULT_CACHE_CONCURRENCY_STRATEGY, "transactional").setProperty(Environment.JPA_SHARED_CACHE_MODE, "ALL").setProperty(Environment.HBM2DDL_AUTO, "create-drop");
    if (cacheKeysFactory != null) {
        configuration.setProperty(Environment.CACHE_KEYS_FACTORY, cacheKeysFactory);
    }
    configuration.addAnnotatedClass(Person.class);
    return configuration.buildSessionFactory();
}
Also used : Configuration(org.hibernate.cfg.Configuration)

Example 49 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 50 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)

Aggregations

Configuration (org.hibernate.cfg.Configuration)190 Test (org.junit.Test)66 Session (org.hibernate.Session)37 SessionFactory (org.hibernate.SessionFactory)35 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)27 Before (org.junit.Before)20 BeforeClass (org.junit.BeforeClass)20 File (java.io.File)18 ServiceRegistry (org.hibernate.service.ServiceRegistry)14 Properties (java.util.Properties)13 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)9 HibernateException (org.hibernate.HibernateException)8 EncapsulatedCompositeIdResultSetProcessorTest (org.hibernate.test.loadplans.process.EncapsulatedCompositeIdResultSetProcessorTest)8 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