Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 167773 - JPA generated PK classes miss def constr
JPA generated PK classes miss def constr
Status: VERIFIED FIXED
Product: java
Classification: Unclassified
Component: Source
6.x
PC Windows Vista
: P2 (vote)
: 6.x
Assigned To: Sergey Petrov
issues@java
:
: 168049 168665 168987 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-29 09:31 UTC by bennyv
Modified: 2009-08-25 19:41 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
The Oracle script (14.59 KB, text/plain)
2009-07-01 11:29 UTC, bennyv
Details
a bit modofied script to run in netbeans for derby sample (except some issues) (13.97 KB, text/plain)
2009-07-16 13:20 UTC, Sergey Petrov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bennyv 2009-06-29 09:31:02 UTC
Whenever I generate entity classes from an existing database that contains multi column primary keys, no default 
constructor is generated for them. The editor also indicates/warns that the default constructor is missing.

I have tested this against Netbeans 6.5 which does generate a default constructor.
I have run the same test with Netbeans RC6.7 RC3 in which the default constructor for a PK-class representing a multi 
column PK is not generated.

I am running Netbeans on 32 bits Windows Vista. The database with which I am testing is Oracle 11g.
Comment 1 Sergey Petrov 2009-07-01 10:04:07 UTC
can you attach schema for your database?
Comment 2 Sergey Petrov 2009-07-01 10:22:20 UTC
or can you try the same with sample database or generated from db schema(if schema is correct) to find out if it's
oracle specific, I tried to create table with two columnt pk in sample and got correct pk class with default no arg
constructor.
it may also be a good luck to have it working in 6.5 as oracle 11g isn't listed as tested platform for 6.7 on
http://www.netbeans.org/community/releases/67/relnotes.html#system_requirements  and this way can't be considered as
fully supported.
Comment 3 Sergey Petrov 2009-07-01 10:32:46 UTC
About working configuration: I tried it with 6.7 release, on java 6, on linux with sample derby database.
Comment 4 bennyv 2009-07-01 11:27:55 UTC
I have tried it with NetBeans FCS this moring as well, when running the following tutorial against a derby database:
http://www.netbeans.org/kb/docs/web/jsf-jpa-crud-wizard.html. I had to manually add the default constructors for PK 
classes ClientPK and ProjectPK.
I will attach a sql script for my Oracle schema as well.
Comment 5 bennyv 2009-07-01 11:29:05 UTC
Created attachment 84231 [details]
The Oracle script
Comment 6 Sergey Petrov 2009-07-01 11:36:35 UTC
ok, looks like I need to try vista, what jdk do you use?
Comment 7 Sergey Petrov 2009-07-01 11:39:13 UTC
thanks for your script.
Which tables did you use in entity classes generation? I see there are a lot..
Comment 8 bennyv 2009-07-01 11:58:33 UTC
In fact I generated entities for them all. 
I just tested it again and have to make some extra remarks:

When I tried to only generate entity class for "Huurovereenkomst" entities "Woning" and "Huurder" were selected as 
well (based on their dependencies). In this case, the default constructor IS created.

Whenever I try to generate the entities for all tables, the default constructor for all PK-classes is omitted...

used jdk: jdk1.6.0_14
Comment 9 Sergey Petrov 2009-07-02 16:57:55 UTC
*** Issue 168049 has been marked as a duplicate of this issue. ***
Comment 10 Sergey Petrov 2009-07-16 12:16:58 UTC
*** Issue 168665 has been marked as a duplicate of this issue. ***
Comment 11 Sergey Petrov 2009-07-16 13:20:59 UTC
Created attachment 84828 [details]
a bit modofied script to run in netbeans for derby sample (except some issues)
Comment 12 Sergey Petrov 2009-07-16 13:34:17 UTC
was abe to reproduce with last script+derby+generate for all tables, got missing def constrctor
Comment 13 Sergey Petrov 2009-07-17 09:07:12 UTC
As I see MethodInfo is created incorrectly also it's created in nbjavac/java.source code, so pass to java-source either
to ask assistance or to find if it's a problem in nb-javac or java.source part and fix it.
Comment 14 Sergey Petrov 2009-07-17 09:41:05 UTC
a bit more details org.netbeans.api.java.source.ElementUtilities::isSynthetic return false for these constructors, but
later when JCClassDecl is rewriten an code is generated, no code for these constructors is generated, so may be code gen
use another method to get if constructor should be in code or not.
Comment 15 Sergey Petrov 2009-07-17 13:23:59 UTC
with Dusan help find a way to fix on my side, but still want to be sure if there is any issue on javac, javac usage size
Comment 16 Sergey Petrov 2009-07-17 13:31:57 UTC
fixed in http://hg.netbeans.org/web-main/rev/d34bfdc6f7ff by switch from ElementUtilities to TreeUtilities.
going to investigate a bit more before closing, not closing, filing related separate issue or any more steps.
Comment 17 Quality Engineering 2009-07-20 09:49:01 UTC
Integrated into 'main-golden', will be available in build *200907200201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/d34bfdc6f7ff
User: sergeyp@netbeans.org
Log: fix #167773 - changed a way to find if constructor is "generated/synthetic"
Comment 18 David Strupl 2009-07-20 12:29:56 UTC
Sergej, can this be marked as fixed?
Comment 19 Sergey Petrov 2009-07-20 14:04:00 UTC
I'm waiting if it will be fixed in root cause by Dusan and also waiting for a response from him.
Comment 20 Sergey Petrov 2009-07-22 10:47:24 UTC
rollback my fix http://hg.netbeans.org/web-main/rev/0a92d5c9582e
issue is fixed in nb javac
Comment 21 Quality Engineering 2009-07-23 07:43:45 UTC
Integrated into 'main-golden', will be available in build *200907230201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/a207acba619f
User: Dusan Balek <dbalek@netbeans.org>
Log: Element coupling should preserve flags from trees (see issue #167773).
Comment 22 Sergey Petrov 2009-07-23 08:54:48 UTC
*** Issue 168987 has been marked as a duplicate of this issue. ***
Comment 23 bennyv 2009-07-23 12:18:17 UTC
I have downloaded the latest development build and tried against my Oracle schema. The default constructors are 
generated by this version of the IDE. Seems ok now.
Comment 24 Michel Graciano 2009-08-25 03:23:06 UTC
User bennyv said it looks fixed. Marked as verified. Please reopen if you think it is still valid.
Comment 25 Michel Graciano 2009-08-25 19:41:15 UTC
v. 200908210201 by user henriquemeira. Thanks Henrique.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo