use of org.jboss.as.test.integration.jpa.hibernate.Employee in project wildfly by wildfly.
the class SessionFactoryTestCase method testInjectPUIntoHibernateSessionFactory.
// Test that a Persistence unit can be injected into a Hibernate Session factory
@Test
public void testInjectPUIntoHibernateSessionFactory() throws Exception {
SFSBHibernateSessionFactory sfsbHibernateSessionFactory = lookup("SFSBHibernateSessionFactory", SFSBHibernateSessionFactory.class);
sfsbHibernateSessionFactory.createEmployee("Sharon", "3 beach ave", 3);
Employee emp = sfsbHibernateSessionFactory.getEmployee(3);
assertTrue("name read from hibernate session is Sharon", "Sharon".equals(emp.getName()));
}
use of org.jboss.as.test.integration.jpa.hibernate.Employee 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()));
}
use of org.jboss.as.test.integration.jpa.hibernate.Employee in project wildfly by wildfly.
the class SessionFactoryTestCase method testHibernateSessionFactoryName.
// test that we didn't break the Hibernate hibernate.session_factory_name (bind Hibernate session factory to
// specified jndi name) functionality.
@Test
public void testHibernateSessionFactoryName() throws Exception {
SFSB1 sfsb1 = lookup("SFSB1", SFSB1.class);
sfsb1.createEmployee("Sally", "1 home street", 1);
// check if we can look up the Hibernate session factory that should of been bound because of
// the hibernate.session_factory_name was specified in the properties (in peristence.xml above).
SessionFactory hibernateSessionFactory = rawLookup("modelSessionFactory", SessionFactory.class);
assertNotNull("jndi lookup of hibernate.session_factory_name should return HibernateSessionFactory", hibernateSessionFactory);
Session session = hibernateSessionFactory.openSession();
Employee emp = session.get(Employee.class, 1);
assertTrue("name read from hibernate session is Sally", "Sally".equals(emp.getName()));
}
use of org.jboss.as.test.integration.jpa.hibernate.Employee in project wildfly by wildfly.
the class ClassFileTransformerTestCase method testhibernate_ejb_use_class_enhancer.
@Test
public void testhibernate_ejb_use_class_enhancer() throws Exception {
SFSB1 sfsb1 = lookup("SFSB1", SFSB1.class);
sfsb1.createEmployee("Kelly Smith", "Watford, England", 10);
sfsb1.createEmployee("Alex Scott", "London, England", 20);
Employee emp = sfsb1.getEmployeeNoTX(10);
assertTrue("was able to read database row with hibernate.ejb.use_class_enhancer enabled", emp != null);
}
Aggregations