This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | JPA Controller Classes from Entity Classes generate code which throws an exception | ||
---|---|---|---|
Product: | javaee | Reporter: | Denis Anisimov <ads> |
Component: | Persistence | Assignee: | Sergey Petrov <sj-nb> |
Status: | VERIFIED FIXED | ||
Severity: | normal | CC: | dkonecny, pjiricka |
Priority: | P3 | ||
Version: | 7.0 | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | |||
Bug Blocks: | 189723 | ||
Attachments: | stacktrace |
Description
Denis Anisimov
2010-12-07 13:40:14 UTC
current behavior will generate usage of getTransaction() if class isn't in container managed environment or isn't managed itself, if it's possible to use such controller as unmanaged it's not an issue but just a feature to generate just one of possible controllers instead of choose between managed and unmanaged. anyway "managed" is passed as a parameter so it shouldn't be an issue for 189723. for ref: in 6.9 next code was used: public HelpCategoryJpaController() { emf = Persistence.createEntityManagerFactory("WebApplication18PU"); } private EntityManagerFactory emf = null; public EntityManager getEntityManager() { return emf.createEntityManager(); } public void create(HelpCategory helpCategory) throws PreexistingEntityException, Exception { EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); in 7.0 EntityManagerFactory and UserTransaction are used as constructor parameters. in my opinion even if current code can be used with some configurations, it's more likely to use jpacontroller with container managed project with JTA resources, and default generation should generate appropriate code, need a bit more investigation. (In reply to comment #1) > current behavior will generate usage of getTransaction() if class isn't in > container managed environment or isn't managed itself web project is "container managed environment", right? so getTransaction should not be used. It looks to me like my comment http://netbeans.org/bugzilla/show_bug.cgi?id=189455#c8 never got implemented. I just generated XxxJpaController classes via "JPA Controller Classes from Entities" wizard and also via "JSF Pages from Entities". And they different which is wrong. One generated for JSF is OK - it uses UserTransaction; first one is wrong as reported by Denis - it uses EntityManager.getTransaction() which cannot be used in JTA transaction type. I need to check how tomcat is reported, also as I know in theory even gf2,3 like servers may support resource_local (according to persistence spec) but in practice do not allow and require JTA pu only. ok, current behavior was introduced based on https://netbeans.org/bugzilla/show_bug.cgi?id=170402 but it wasn't real fix, also there is no entity manager factory etc creation in controller itself, so I'll rollback changeset from issue 170402 old default behavior is reverted, only container or not is used now http://hg.netbeans.org/web-main/rev/dc64c5535f53 also as I see 170402 affect default constructor realization (with inner factory and transaction objects creation). Integrated into 'main-golden', will be available in build *201012090001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/dc64c5535f53 User: Sergey B. Petrov <sj-nb@netbeans.org> Log: fix #192981 behavior is reverted, only conteiner or not is used now without additional parameters |