use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class BatchVersionedDataConfigTest method setUp.
@Before
public void setUp() {
cfg = new Configuration();
// HHH-10290 ignore environment property hibernate.jdbc.batch_versioned_data
if (cfg.getProperties().getProperty(AvailableSettings.BATCH_VERSIONED_DATA) != null) {
cfg.getProperties().remove(AvailableSettings.BATCH_VERSIONED_DATA);
cfg.getStandardServiceRegistryBuilder().getSettings().remove(AvailableSettings.BATCH_VERSIONED_DATA);
}
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class CacheConfigurationTest method testCacheConfiguration.
@Test
public void testCacheConfiguration() throws Exception {
// we only care if the SF builds successfully.
Configuration cfg = new Configuration().configure(CFG_XML);
cfg.buildSessionFactory().close();
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class AttributeConverterTest method testErrorInstantiatingConverterClass.
@Test
public void testErrorInstantiatingConverterClass() {
Configuration cfg = new Configuration();
try {
cfg.addAttributeConverter(BlowsUpConverter.class);
fail("expecting an exception");
} catch (AnnotationException e) {
assertNotNull(e.getCause());
assertTyping(BlewUpException.class, e.getCause());
}
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class AttributeConverterTest method testBasicUsage.
@Test
public void testBasicUsage() {
Configuration cfg = new Configuration();
cfg.addAttributeConverter(IntegerToVarcharConverter.class, false);
cfg.addAnnotatedClass(Tester4.class);
cfg.setProperty(AvailableSettings.HBM2DDL_AUTO, "create-drop");
cfg.setProperty(AvailableSettings.GENERATE_STATISTICS, "true");
SessionFactory sf = cfg.buildSessionFactory();
try {
Session session = sf.openSession();
session.beginTransaction();
session.save(new Tester4(1L, "steve", 200));
session.getTransaction().commit();
session.close();
sf.getStatistics().clear();
session = sf.openSession();
session.beginTransaction();
session.get(Tester4.class, 1L);
session.getTransaction().commit();
session.close();
assertEquals(0, sf.getStatistics().getEntityUpdateCount());
session = sf.openSession();
session.beginTransaction();
Tester4 t4 = (Tester4) session.get(Tester4.class, 1L);
t4.code = 300;
session.getTransaction().commit();
session.close();
session = sf.openSession();
session.beginTransaction();
t4 = (Tester4) session.get(Tester4.class, 1L);
assertEquals(300, t4.code.longValue());
session.delete(t4);
session.getTransaction().commit();
session.close();
} finally {
sf.close();
}
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class LoadPlanStructureAssertionTest method testJoinedOneToOne.
@Test
public void testJoinedOneToOne() {
// tests the mappings defined in org.hibernate.test.onetoone.joined.JoinedSubclassOneToOneTest
Configuration cfg = new Configuration();
cfg.addResource("org/hibernate/test/onetoone/joined/Person.hbm.xml");
SessionFactoryImplementor sf = (SessionFactoryImplementor) cfg.buildSessionFactory();
try {
// doCompare( sf, (OuterJoinLoadable) sf.getClassMetadata( org.hibernate.test.onetoone.joined.Person.class ) );
doCompare(sf, (OuterJoinLoadable) sf.getClassMetadata(org.hibernate.test.onetoone.joined.Entity.class));
// doCompare( sf, (OuterJoinLoadable) sf.getClassMetadata( org.hibernate.test.onetoone.joined.Address.class ) );
} finally {
sf.close();
}
}
Aggregations