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 188281 - JSF from Database wizard leds to uncompilable converter code
Summary: JSF from Database wizard leds to uncompilable converter code
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 6.x
Hardware: All All
: P2 normal (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-01 14:23 UTC by javydreamercsw
Modified: 2010-08-27 03:16 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample Project (412.66 KB, application/x-zip-compressed)
2010-07-01 14:24 UTC, javydreamercsw
Details
WebApplication69 sample project (28.80 KB, application/x-zip-compressed)
2010-08-13 12:42 UTC, Martin Schovanek
Details
screen (63.39 KB, image/png)
2010-08-16 08:07 UTC, Alexey Butenko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description javydreamercsw 2010-07-01 14:23:43 UTC
getAsString method has errors if the Entity has a primary key class complaining it has no setter methods.

Here's the generated comment in the code:

// TODO: no setter methods were found in your primary key class
            //    persistence.XincoAddAttributePK
            // and therefore getAsString() method could not be pre-generated.

Will attach project for review.
Comment 1 javydreamercsw 2010-07-01 14:24:32 UTC
Created attachment 100545 [details]
Sample Project
Comment 2 Martin Schovanek 2010-08-02 12:31:55 UTC
to reproduce:
1) create a new Web Application, GF v3.0.1, Java EE 6 Web
2) generate Entity Classes from jdbc/sample database for all tables
3) generate JSF Pages from Entity Classes for all the entities
ERROR: LCustController.java is uncompilable. The problem is L_CUST view table which does not have a primary key. IMHO we should not generate the JSF Pages for entities like this.
Comment 3 Alexey Butenko 2010-08-13 07:49:22 UTC
(In reply to comment #2)
> to reproduce:
> 1) create a new Web Application, GF v3.0.1, Java EE 6 Web
> 2) generate Entity Classes from jdbc/sample database for all tables
> 3) generate JSF Pages from Entity Classes for all the entities
> ERROR: LCustController.java is uncompilable. The problem is L_CUST view table
> which does not have a primary key. IMHO we should not generate the JSF Pages
> for entities like this.

Martin I don't see L_CUST view table in GF 3.0.1, and Entity classes wizard will not allow you to create entity classes for tables without Primary Key.

According to sample project submitted by reporter, there was wrongly generated code, which is not reproducible on the recent builds. Mark as INCOMPLETE for now.
Comment 4 Martin Schovanek 2010-08-13 12:35:52 UTC
In fact the wizard allows to create entity classes for tables without Primary Key.
But there is a warning: 'You will likely need to specify Entity IDs for selected views (hint can be used).' And the generated LCust.java is compilable but there is a warning: 'There is not ID defined for this entity hierarchy'. So the JSF wizard should refuse to generate the JSF Pages for entity classes without IDs.
Comment 5 Martin Schovanek 2010-08-13 12:40:35 UTC
to reproduce 2:
---------------
1) open the attached WebApplication69 project
2) generate JSF Pages from Entity Classes for all the entities
ERROR: LCustController.java is uncompilable.
Comment 6 Martin Schovanek 2010-08-13 12:42:09 UTC
Created attachment 101374 [details]
WebApplication69 sample project
Comment 7 Alexey Butenko 2010-08-16 08:04:40 UTC
I'm not able to create JSF Pages with the attached project since since there is no any entities available in the wizard. What build you are using?  Could you provide the structure of the table?
Attached screenshot of the wizard with table with no primary key.
Comment 8 Alexey Butenko 2010-08-16 08:07:16 UTC
Created attachment 101406 [details]
screen
Comment 9 Martin Schovanek 2010-08-16 09:55:27 UTC
You are right, you cannot create entity classes for tables without Primary Key. But you can for VIEWS. Try to create 'CUST_VIEW' for 'SELECT * FROM CUSTOMER' QUERY. It does not have a primary key but you can generate entity class for it.  I'm using trunk dev builds now: 201008130001.
Comment 10 Sergey Petrov 2010-08-16 10:01:32 UTC
If I remember right there is a warning for views and also some TODO in generated code, in my opinion problems are expected and user is warned for the case if no updates for entities was done after generation. But it may be good to handle absence of primary keys in jsf wizard.
Comment 11 Alexey Butenko 2010-08-16 12:06:51 UTC
reproduced, get UNDEFINED word instead of type.
Discussed with Sergey, and agreed that it would be good to disable addition of the entity classes without IDs for JSF Pages generation in the wizard, reassigning, since entity classes collected in the Persistence module.
Comment 12 Sergey Petrov 2010-08-17 08:45:48 UTC
will try to block jsf/jsp pages creation from entities without pk.

Initial logic for current implementation was not to block user as 
- user is warned at entity creation step
- if user made no correction user will get uncompilable code instead of some compilable draft but with problem at runtime. compilation problems should bring user attention to the problem in attempt to fix/complete code, it's intended.
Comment 13 Quality Engineering 2010-08-18 03:23:21 UTC
Integrated into 'main-golden', will be available in build *201008180001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/730f80b27b2d
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: fix #188281 just started, look for ui update to handle 'no pk' case
Comment 14 Quality Engineering 2010-08-26 03:23:04 UTC
Integrated into 'main-golden', will be available in build *201008260001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/ab2c21ed9355
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: fix #188281 - some api changes and additional dependency to get access to TypeElement from Entity
Comment 15 Sergey Petrov 2010-08-26 10:56:46 UTC
http://hg.netbeans.org/web-main/rev/1be1517638fd
Generation of jsf pages shouldn't be possible to entities without id now. As there are a lot of chages it's good it's some time before release for testing/feedback.
Comment 16 Quality Engineering 2010-08-27 03:16:30 UTC
Integrated into 'main-golden', will be available in build *201008270001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/cdca59a654dc
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: fix #188281 - additional cleanup for unused controller parameter