[ 
https://issues.apache.org/jira/browse/OOZIE-143?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Roman Shaposhnik reopened OOZIE-143:
------------------------------------


> GH-117: Refactor DB access to JPA
> ---------------------------------
>
>                 Key: OOZIE-143
>                 URL: https://issues.apache.org/jira/browse/OOZIE-143
>             Project: Oozie
>          Issue Type: Bug
>            Reporter: Hadoop QA
>
> All JPA access should be done using the following:
>     public interface JPACommand {
>         public void call(EntityManager em) throws JPACommandException;
>     }
>     //This replaces current StoreService
>     public class JPAAccessorService implements Service {
>         private EntityManagerFactory emf;
>         @Override
>         public void init(Services services) throws ServiceException {
>             //create EMF
>         }
>         @Override
>         public void destroy() {
>             //destroy EMF
>         }
>         @Override
>         public Class<? extends Service> getInterface() {
>             return JPAAccessorService.class;
>         }
>         public void execute(JPACommand jpaCommand) throws JPACommandException 
> {
>             //all instrumentation is missing here
>             EntityManager em = emf.createEntityManager();
>             try {
>                 jpaCommand.call(em);
>             }
>             finally {
>                 // check if TRX is open, log WARNING
>                 // rollback TRX
>                 em.close();
>             }
>         }
>     }
> Also, JPA named queries should be used ONLY to do SELECT QUERIES. All 
> modifications of bean should be done using
> attached beans.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to