use of org.jboss.as.test.integration.jpa.hibernate.entity.Customer in project wildfly by wildfly.
the class EntityTest method testCustomerByIdQuery.
public Customer testCustomerByIdQuery() {
Customer c = new Customer();
c.setName("Peter");
session.save(c);
session.flush();
return (Customer) session.getNamedQuery("customerById").setParameter("id", c.getId()).uniqueResult();
}
use of org.jboss.as.test.integration.jpa.hibernate.entity.Customer in project wildfly by wildfly.
the class EntityTest method changeCustomer.
public void changeCustomer(Long id, String name) {
Customer c = session.load(Customer.class, id);
c.setName(name);
}
use of org.jboss.as.test.integration.jpa.hibernate.entity.Customer in project wildfly by wildfly.
the class EntityTest method oneToManyCreate.
public Customer oneToManyCreate() throws Exception {
Ticket t = new Ticket();
t.setNumber("111");
Customer c = new Customer();
Set<Ticket> tickets = new HashSet<Ticket>();
tickets.add(t);
t.setCustomer(c);
c.setTickets(tickets);
session.save(c);
return c;
}
use of org.jboss.as.test.integration.jpa.hibernate.entity.Customer in project wildfly by wildfly.
the class EntityTestCase method testNamedQueries.
@Test
@InSequence(4)
public void testNamedQueries() throws Exception {
EntityTest test = lookup("EntityTest", EntityTest.class);
int count = test.testAllCustomersQuery();
assertEquals("Number returned for allCustomers query", 4, count);
Customer c = test.testCustomerByIdQuery();
assertNotNull("One object should be returned by customerById query", c);
}
use of org.jboss.as.test.integration.jpa.hibernate.entity.Customer in project wildfly by wildfly.
the class EntityTestCase method testFlush.
@Test
@InSequence(5)
public void testFlush() throws Exception {
EntityTest test = lookup("EntityTest", EntityTest.class);
Customer c = test.createCustomer("Thomas");
test.changeCustomer(c.getId(), "George");
Customer c2 = test.findCustomerById(c.getId());
assertEquals("George", c2.getName());
}
Aggregations