use of org.hibernate.jpa.HibernateEntityManagerFactory in project hibernate-orm by hibernate.
the class EntityManagerFactoryUnwrapTest method testEntityManagerCanBeUnwrappedToHibernateEntityManagerFactory.
@Test
public void testEntityManagerCanBeUnwrappedToHibernateEntityManagerFactory() {
org.hibernate.jpa.HibernateEntityManagerFactory hibernateEntityManagerFactory = entityManagerFactory.unwrap(org.hibernate.jpa.HibernateEntityManagerFactory.class);
assertNotNull("Unwrapping to SPI class HibernateEntityManagerFactory should be ok", hibernateEntityManagerFactory);
}
use of org.hibernate.jpa.HibernateEntityManagerFactory in project hibernate-orm by hibernate.
the class MappingClassMoreThanOnceTest method testBootstrapWithClassMappedMOreThanOnce.
/**
* Tests that an entity manager can be created when a class is mapped more than once.
*/
@Test
@TestForIssue(jiraKey = "HHH-8775")
public // @FailureExpected(jiraKey = "HHH-8775")
void testBootstrapWithClassMappedMOreThanOnce() {
Map settings = new HashMap();
settings.put(AvailableSettings.HBXML_FILES, "org/hibernate/jpa/test/callbacks/hbmxml/ClassMappedMoreThanOnce.hbm.xml");
final EntityManagerFactoryBuilder builder = Bootstrap.getEntityManagerFactoryBuilder(new BaseEntityManagerFunctionalTestCase.TestingPersistenceUnitDescriptorImpl(getClass().getSimpleName()), settings);
HibernateEntityManagerFactory emf = null;
try {
emf = builder.build().unwrap(HibernateEntityManagerFactory.class);
} finally {
if (emf != null) {
try {
emf.close();
} catch (Exception ignore) {
}
}
}
}
use of org.hibernate.jpa.HibernateEntityManagerFactory in project wildfly by wildfly.
the class HibernateCollectionStatistics method getBaseStatistics.
private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) {
if (entityManagerFactory == null) {
return null;
}
HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory;
SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory();
if (sessionFactory != null) {
return sessionFactory.getStatistics();
}
return null;
}
use of org.hibernate.jpa.HibernateEntityManagerFactory in project wildfly by wildfly.
the class HibernateCollectionStatistics method getStatistics.
private CollectionStatistics getStatistics(final EntityManagerFactory entityManagerFactory, String collectionName) {
if (entityManagerFactory == null) {
return null;
}
HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory;
SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory();
if (sessionFactory != null) {
return sessionFactory.getStatistics().getCollectionStatistics(collectionName);
}
return null;
}
use of org.hibernate.jpa.HibernateEntityManagerFactory in project wildfly by wildfly.
the class HibernateEntityStatistics method getStatistics.
private org.hibernate.stat.EntityStatistics getStatistics(EntityManagerFactory entityManagerFactory, String entityName) {
if (entityManagerFactory == null) {
return null;
}
HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory;
SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory();
if (sessionFactory != null) {
return sessionFactory.getStatistics().getEntityStatistics(entityName);
}
return null;
}
Aggregations