protected void save(final Customer customer) { transactionStrategy.execute( new JpaCallback() { public Object doInJpa(EntityManager entityManager) throws PersistenceException { entityManager.persist(customer); entityManager.flush(); return null; } }); assertEntitiesInDatabase(1, Customer.class.getName()); assertEntitiesInDatabase(1, Address.class.getName()); }
protected void setUp(String endpointUri) throws Exception { template = camelContext.createProducerTemplate(); startServices(template, camelContext); endpoint = camelContext.getEndpoint(endpointUri, JpaEndpoint.class); transactionStrategy = endpoint.createTransactionStrategy(); jpaTemplate = endpoint.getTemplate(); transactionStrategy.execute( new JpaCallback() { public Object doInJpa(EntityManager entityManager) throws PersistenceException { entityManager.createQuery("delete from " + Customer.class.getName()).executeUpdate(); return null; } }); assertEntitiesInDatabase(0, Customer.class.getName()); assertEntitiesInDatabase(0, Address.class.getName()); }