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.
The JSF Pages from Entity Classes wizard generates code that is not in accordance with the usage of the Java Persistence API. More specifically, application-managed persistence context are not properly synchronized with JTA transactions. This causes for example silent failures when inserting data. Steps: 1. Create a new wep application on SJSAS/GF 2. Create an entity class and a persistence unit using JTA 3. Create JSF pages from the entity => in the created controller class the following code is generated: public String create() { EntityManager em = getEntityManager(); try { utx.begin(); em.persist(entity); utx.commit(); .... The problem with this is that the entity manager is created outside of the active transaction scope and therefore it is not synchronized with the transaction. Because of this the persistence context is not flushed before the transaction commits and hence nothing is inserted into the database. This can be fixed either by creating the entity manager within the transaction scope or by invoking em.joinTransaction() inside the scope.
Created attachment 36575 [details] proposed patch
Attached is a patch for this issue. The patch adds a call to em. joinTransaction() after the user transaction has started.
The fix is ok for me.
Fixed in release55 branch. http://web.netbeans.org/source/browse/web/jsf/src/org/netbeans/modules/web/jsf/wizards/JSFClinetGenerator.java?r1=1.1.2.47&r2=1.1.2.48
Verified in 5.5 continuous build1220-1213.
Reverted the previous commit in release55 branch. http://web.netbeans.org/source/browse/web/jsf/src/org/netbeans/modules/web/jsf/wizards/JSFClinetGenerator.java?r1=1.1.2.48&r2=1.1.2.49 The patch in desc2 contains a typo, the actual patch that was verified in release55 branch is the one linked from desc5.
Fixed in release551 branch. Checking in JSFClinetGenerator.java; /cvs/web/jsf/src/org/netbeans/modules/web/jsf/wizards/ JSFClinetGenerator.java,v <-- JSFClinetGenerator.java new revision: 1.1.2.47.8.1; previous revision: 1.1.2.47 done
*** Issue 104301 has been marked as a duplicate of this issue. ***
verified Product Version: NetBeans IDE Dev (Build 200811011401) Java: 1.6.0_10-rc2; Java HotSpot(TM) Client VM 11.0-b15 System: Linux version 2.6.24-21-generic running on i386; UTF-8; en_US (nb)