use of org.jboss.as.test.integration.jpa.hibernate.SFSBHibernateSession in project wildfly by wildfly.
the class SessionFactoryTestCase method testInjectPCIntoHibernateSession.
// Test that an extended Persistence context can be injected into a Hibernate Session
// We use extended persistence context, otherwise the Hibernate session will be closed after each transaction and
// the assert test would fail (due to lazy loading of the Employee entity.
// Using extended persistence context allows the hibernate session to stay open long enough for the lazy fetch.
@Test
public void testInjectPCIntoHibernateSession() throws Exception {
SFSBHibernateSession sfsbHibernateSession = lookup("SFSBHibernateSession", SFSBHibernateSession.class);
sfsbHibernateSession.createEmployee("Molly", "2 apple way", 2);
Employee emp = sfsbHibernateSession.getEmployee(2);
assertTrue("name read from hibernate session is Molly", "Molly".equals(emp.getName()));
}
Aggregations