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.
[ JDK VERSION : 1.5.0_06 ] I get an "Unexpected Error" message when generating entities from database with the schema attached below. I am using derby as the database. create table CUSTOMER ( ID INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, FIRST_NAME VARCHAR(255), MIDDLE_NAME VARCHAR(255), LAST_NAME VARCHAR(255), PRIMARY_ADDRESS_LINE1 VARCHAR(255), PRIMARY_ADDRESS_LINE2 VARCHAR(255), PRIMARY_ADDRESS_CITY VARCHAR(255), PRIMARY_ADDRESS_STATE_ID INTEGER, PRIMARY_ADDRESS_ZIP VARCHAR(255), SECONDARY_ADDRESS_LINE1 VARCHAR(255), SECONDARY_ADDRESS_LINE2 VARCHAR(255), SECONDARY_ADDRESS_CITY VARCHAR(255), SECONDARY_ADDRESS_STATE_ID INTEGER, SECONDARY_ADDRESS_ZIP VARCHAR(255) ); create table STATE( ID INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, NAME VARCHAR(255) NOT NULL, CODE VARCHAR(255) NOT NULL ); ALTER TABLE STATE ADD CONSTRAINT INDEX_STATE_NAME UNIQUE (NAME); ALTER TABLE STATE ADD CONSTRAINT INDEX_STATE_CODE UNIQUE (CODE); alter table CUSTOMER add constraint FK_CUSTOMER_PRIMARY_ADDRESS_STATE_ID foreign key (PRIMARY_ADDRESS_STATE_ID) references STATE (ID); alter table CUSTOMER add constraint FK_CUSTOMER_SECONDARY_ADDRESS_STATE_ID foreign key (SECONDARY_ADDRESS_STATE_ID) references STATE (ID);
I can reproduce. The problem is that the list of inverse column names for setting up the JoinColumn referencedColumnName annotation for the field corresponding to SECONDARY_ADDRESS_STATE_ID in class Customer is null. I'm not sure why yet, but I'm looking into it.
More info - the problem is that 1) there are 2 fks in CUSTOMER to STATE.ID (one on PRIMARY_ADDRESS_STATE_ID and one on SECONDARY_ADDRESS_STATE_ID) 2) the uniqueing cleanup of DbSchemaEjbGenerator.makeBeansUnique updated in the fix for issue 80084 (see <http://www.netbeans.org/source/browse/j2ee/persistence/src/org/netbeans/modules/j2ee/persistence/entitygenerator/Attic/DbSchemaEjbGenerator.java?r1=1.1.2.1.2.10&r2=1.1.2.1.2.11>) *removes* the second cmr field mapping from the map
If I remove Andrei's fix for issue 80084, this bug is fixed and I can't seem to reproduce issue 80084. I tried to do so using the ddl Pavel had in issue 80084, but I no longer have both a cmp and cmr field for the overlap. I'll attach a dbschema with 4 tables - 2 based on the ones in this issue and 2 based on the ones in issue 80084. Transferring to Andrei after discussion with Pavel.
Created attachment 33339 [details] dbschema file
Yes, it seems my "fix" can be removed, because the CMR mapping already contains the uniquified field names. Rochelle, thank you for spending time on this! Checking in DbSchemaEjbGenerator.java; /cvs/j2ee/persistence/src/org/netbeans/modules/j2ee/persistence/entitygenerator/Attic/DbSchemaEjbGenerator.java,v <-- DbSchemaEjbGenerator.java new revision: 1.1.2.1.2.12; previous revision: 1.1.2.1.2.11 done