On 30-Mar-2010 09:34, Wesley Wu wrote: > To make set method auto translated into a UPDATE clause, the > entitymanager should be opened after a transaction begins. > > Sincere thanks again, hopefully this will all help others coming across it in the future.
If I understood you correctly I made those changes and now get example.CourseServlet.emf : @PersistenceContext field must be assignable from EntityManager. Heres the new full servlet: package example; import java.io.IOException; import java.io.PrintWriter; import javax.inject.Inject; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.PersistenceContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.transaction.UserTransaction; public class CourseServlet extends HttpServlet { // Resin IoC will inject this @PersistenceContext(unitName="example") EntityManagerFactory emf; @Inject private UserTransaction ut; public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { PrintWriter out = response.getWriter(); response.setContentType("text/html"); EntityManager em = null; try { ut.begin(); em = emf.createEntityManager(); CourseBean updateCourse = em.find(CourseBean.class, new Integer(1)); updateCourse.setCourse("Magic"); ut.commit(); } catch (Exception e) { e.printStackTrace(); } finally { if (em != null && em.isOpen()) { em.close(); } } } } _______________________________________________ resin-interest mailing list resin-interest@caucho.com http://maillist.caucho.com/mailman/listinfo/resin-interest