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 211538 - Eclipselink errors running code created by Entities from Database wizard
Summary: Eclipselink errors running code created by Entities from Database wizard
Status: RESOLVED INVALID
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 7.2
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-20 22:26 UTC by javydreamercsw
Modified: 2012-04-27 18:52 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample project (253.65 KB, application/x-java-archive)
2012-04-20 22:28 UTC, javydreamercsw
Details
Correct class example (4.24 KB, text/x-java)
2012-04-20 22:28 UTC, javydreamercsw
Details
MySQL Workbench file (70.66 KB, application/octet-stream)
2012-04-27 17:22 UTC, javydreamercsw
Details
MySQL script (59.61 KB, application/octet-stream)
2012-04-27 17:24 UTC, javydreamercsw
Details

Note You need to log in before you can comment on or make changes to this bug.
Description javydreamercsw 2012-04-20 22:26:32 UTC
Product Version = NetBeans IDE Dev (Build 201204200400)
Operating System = Windows 7 version 6.1 running on x86
Java; VM; Vendor = 1.7.0_03
Runtime = Java HotSpot(TM) Client VM 22.1-b02

I got a couple of Incomplete Join Columns errors when trying to run code generated by the wizard. For example:

Exception Description: The @JoinColumns on the annotated element [field riskItem] from the entity class [class jpa.issue.RiskItemHasRiskCategory] is incomplete. When the source entity class uses a composite primary key, a @JoinColumn must be specified for each join column using the @JoinColumns. Both the name and the referencedColumnName elements must be specified in each such @JoinColumn.

To reproduce:
1) Run main method in attached project.

Compare the classes: RiskItemHasRiskCategory with the attached working one.

The working classes can be seen from: https://validationmgr.svn.sourceforge.net/svnroot/validationmgr (trunk rev 12)
Comment 1 javydreamercsw 2012-04-20 22:28:51 UTC
Created attachment 118582 [details]
Sample project
Comment 2 javydreamercsw 2012-04-20 22:28:54 UTC
Created attachment 118583 [details]
Correct class example
Comment 3 Jiri Kovalsky 2012-04-24 19:31:41 UTC
Reassigning for evaluation in javaee team.
Comment 4 Sergey Petrov 2012-04-25 08:53:15 UTC
can you provide some sample sql for evaluation?
Comment 5 Sergey Petrov 2012-04-25 09:05:48 UTC
thanks, found schema in attached project
Comment 6 Sergey Petrov 2012-04-25 09:43:50 UTC
found 211691  with attached project also.
Comment 7 Sergey Petrov 2012-04-27 15:13:48 UTC
If I got it right in case of composite primary key all columns should be referenced in foreign key first and in provided schema only one column is referenced in risk_item_has_risk_category.fk_risk_item_has_risk_category_risk_item1
in this case it may be either db issue, may be wrong fk is created and allowed by db or may be schema capture issue.
Can you provide sql script used to create tables?
Comment 8 Sergey Petrov 2012-04-27 15:45:32 UTC
tried next:
CREATE TABLE AWITHCOMPOSITE
(
ID1 Integer,
ID2 VARCHAR(10),
NAME VARCHAR(20),
PRIMARY KEY(ID1,ID2)
)
CREATE TABLE AWITHFORKEYTOCOMPOSITE
(
ID Integer,
NAME VARCHAR(10),
REFID1 Integer,
REFID2 VARCHAR(10),
PRIMARY KEY (ID),
FOREIGN KEY (REFID1,REFID2) REFERENCES AWITHCOMPOSITE(ID1,ID2)
)
capture schema, create entities and got correct
    @JoinColumns({
        @JoinColumn(name = "REFID1", referencedColumnName = "ID1"),
        @JoinColumn(name = "REFID2", referencedColumnName = "ID2")})

it's unclear if there is any error on nb side so far, please provide more information.
Comment 9 javydreamercsw 2012-04-27 17:22:51 UTC
Created attachment 118887 [details]
MySQL Workbench file

I'll generate and attach the script in a bit.
Comment 10 javydreamercsw 2012-04-27 17:24:45 UTC
Created attachment 118888 [details]
MySQL script
Comment 11 javydreamercsw 2012-04-27 17:25:03 UTC
Attached required script.
Comment 12 Sergey Petrov 2012-04-27 17:46:27 UTC
according to script foreign key declaration isn't complete

    FOREIGN KEY (`risk_item_id` )
    REFERENCES `validation_manager`.`risk_item` (`id` )

in this case ide just generate what it can see, at most ide can try to verify incomplete constraint at some step. in my opinion this issue isn't valid.
Comment 13 Sergey Petrov 2012-04-27 18:05:29 UTC
moreover this table contain just 3 columns and only one correspond to another in risk_item, there is no one to match fmea_id from risk_item
Comment 14 Sergey Petrov 2012-04-27 18:12:30 UTC
one more point, if I'll run an application with "create tables" mode with "corrected" joincolumns, I'll get risk_item_has_risk_category with 4 columns
Comment 15 javydreamercsw 2012-04-27 18:52:57 UTC
I agree. I corrected the MySQL Workbench file and script. After that the files where correctly generated.