O'Reilly logo

Drools JBoss Rules 5.X Developer's Guide by Michal Bali

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Repositories

The infrastructure for the persistence layer is almost set up (only the transaction setup is missing). We can implement the repositories that will be responsible for persistence and lookup of the domain objects. Let's start with the JPACustomerRepository interface. The JPACustomerRepository interface uses the EntityManagerto property to find a customer by the customerUuid field, find customers by the first and last name, and also to add a new customer or update an existing one:

@Repository public class JPACustomerRepository implements CustomerRepository { @PersistenceContext private EntityManager em; public Customer findCustomerByUuid(String customerUuid) { return em.find(Customer.class, customerUuid); } public List<Customer> findCustomerByName(String ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required