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.

Bug 193491 - Generating REST services from entities produces uncompilable code
Summary: Generating REST services from entities produces uncompilable code
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 7.0
Hardware: All All
: P2 normal (vote)
Assignee: Sergey Petrov
URL:
Keywords:
: 193611 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-12-16 12:52 UTC by Petr Jiricka
Modified: 2010-12-19 22:43 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2010-12-16 12:52:55 UTC
1. Create a web project with GF 3.1 target
2. Create entities from database
3. Create REST services from these entities

The wizard will generate the following in the REST service:

    protected EntityManager getEntityManager() {
        try {
            utx.begin();
            return em;
            utx.commit();
        } catch (Exception e) {
            ...
        }
    }

I.e. an unreachable utx.commit() statement.

Since this generated class is a @Stateless session bean, is the utx variable needed at all?
Comment 1 Denis Anisimov 2010-12-16 13:20:08 UTC
First of all : I cannot reproduce it with my dev build.
It means that this is recent change.

The second : this is not REST bug.
The EntityManager accessor is generated via org.netbeans.modules.j2ee.persistence.action.EntityManagerGenerator.generate().

REST generation code modifies only annotations for generated method.
The body of this method is not changed .

So this is the issue inside persistence module code.
Comment 2 Sergey Petrov 2010-12-16 15:02:57 UTC
yes, it may be recent change related to 189559, but utx usage should be for non ejb classes only, but if ejb was just created it may not be in model yet, not which part of code should consider this behavior.
and I don't remember any code like
            utx.begin();
            return em;
            utx.commit();
but will look.
Comment 3 Sergey Petrov 2010-12-16 17:11:46 UTC
here is fast fix, it may be good but also it may be good to move transaction wrapping to GenerationOptions itself.
http://hg.netbeans.org/web-main/rev/bcf72c65d958
Comment 4 Quality Engineering 2010-12-17 06:19:58 UTC
Integrated into 'main-golden', will be available in build *201012170001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/bcf72c65d958
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: fix #193491 - exclude some operations from eligib;le for transactions if non ejb
Comment 5 David Konecny 2010-12-19 22:43:23 UTC
*** Bug 193611 has been marked as a duplicate of this bug. ***