use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class FetchProfileTest method testPackageConfiguredFetchProfile.
@Test
public void testPackageConfiguredFetchProfile() {
Configuration config = new Configuration();
config.addAnnotatedClass(Customer.class);
config.addAnnotatedClass(Order.class);
config.addAnnotatedClass(SupportTickets.class);
config.addAnnotatedClass(Country.class);
config.addPackage(Customer.class.getPackage().getName());
SessionFactoryImplementor sessionImpl = (SessionFactoryImplementor) config.buildSessionFactory(serviceRegistry);
assertTrue("fetch profile not parsed properly", sessionImpl.containsFetchProfileDefinition("package-profile-1"));
assertTrue("fetch profile not parsed properly", sessionImpl.containsFetchProfileDefinition("package-profile-2"));
sessionImpl.close();
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class MappedSuperclassTestTask method prepare.
public void prepare() {
Configuration cfg = new Configuration();
cfg.setProperty(Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true");
cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
super.prepare(cfg);
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class LazyCollectionWithClearedSessionTestTask method prepare.
public void prepare() {
Configuration cfg = new Configuration();
cfg.setProperty(Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true");
cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
super.prepare(cfg);
try (Session s = getFactory().openSession()) {
s.beginTransaction();
try {
Store store = new Store(1).setName("Acme Super Outlet");
s.persist(store);
Product product = new Product("007").setName("widget").setDescription("FooBar");
s.persist(product);
store.addInventoryProduct(product).setQuantity(10L).setStorePrice(new BigDecimal(500));
s.getTransaction().commit();
} catch (Exception e) {
if (s.getTransaction().isActive()) {
s.getTransaction().rollback();
}
throw e;
}
}
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class LazyCollectionWithClosedSessionTestTask method prepare.
public void prepare() {
Configuration cfg = new Configuration();
cfg.setProperty(Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true");
cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
super.prepare(cfg);
try (Session s = getFactory().openSession()) {
s.beginTransaction();
try {
Store store = new Store(1).setName("Acme Super Outlet");
s.persist(store);
Product product = new Product("007").setName("widget").setDescription("FooBar");
s.persist(product);
store.addInventoryProduct(product).setQuantity(10L).setStorePrice(new BigDecimal(500));
s.getTransaction().commit();
} catch (Exception e) {
if (s.getTransaction().isActive()) {
s.getTransaction().rollback();
}
throw e;
}
}
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class LazyEntityLoadingWithClosedSessionTestTask method prepare.
public void prepare() {
Configuration cfg = new Configuration();
cfg.setProperty(Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true");
cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
super.prepare(cfg);
try (Session s = getFactory().openSession()) {
s.beginTransaction();
try {
Store store = new Store(1).setName("Acme Super Outlet");
s.persist(store);
Product product = new Product("007").setName("widget").setDescription("FooBar");
s.persist(product);
store.addInventoryProduct(product).setQuantity(10L).setStorePrice(new BigDecimal(500));
s.getTransaction().commit();
} catch (Exception e) {
if (s.getTransaction().isActive()) {
s.getTransaction().rollback();
}
throw e;
}
}
}
Aggregations