Java Magazine, Nov/Dec 2017
ORACLE COM JAVAMAGAZINE NOVEMBER DECEMBER 2017 36 java ee 8 persistence The EmployeeService shown above is a plain CDI bean and it doesnt have any transactional semantics of its own Yet per the requirements of EntityManager persist a transaction is required for that method to do its work Possibly the service has been written with the assumption that the client starts that transaction If the service wasnt you modify the code directly to add @ Transactional to the persist method and the CDI 20 InterceptionFactory can be used again to dynamically add it The full producer method is shown below @ Produces public EmployeeService produce InterceptionFactory EmployeeService interceptionFactory BeanManager beanManager EmployeeService employeeBean createRef beanManager resolve beanManager getBeans EmployeeService class stream filter e e getBeanClass equals ApplicationInit class collect toSet beanManager interceptionFactory configure filterMethods am am getJavaMember getName equals persist forEach amc amc add new TransactionLiteral
You must have JavaScript enabled to view digital editions.