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.
Created attachment 93391 [details] DB Schema 6.8 jdk 1.6.18 I got the following error: The @JoinColumns on the annotated element [field xincoWorkflow] from the entity class [class com.bluecubs.xinco.workflow.persistence.XincoWorkflowState] 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. After further investigation the @JoinColumns definition in the class XincoWorkflowState that references XincoWorkflow was missing one of the components of XincoWorkflow composite key. Manually adding it did the trick. The original definition was: @JoinColumns({ @JoinColumn(name = "xinco_workflow_id", referencedColumnName = "id", nullable = false, insertable = false, updatable = false), @JoinColumn(name = "xinco_workflow_version", referencedColumnName = "version", nullable = false, insertable = false, updatable = false)}) @ManyToOne(optional = false, fetch = FetchType.LAZY) private XincoWorkflow xincoWorkflow; The modified definition: @JoinColumns({ @JoinColumn(name = "xinco_workflow_id", referencedColumnName = "id", nullable = false, insertable = false, updatable = false), @JoinColumn(name = "user_link_id", referencedColumnName = "userLinkId", nullable = false, insertable = false, updatable = false), @JoinColumn(name = "xinco_workflow_version", referencedColumnName = "version", nullable = false, insertable = false, updatable = false)}) @ManyToOne(optional = false, fetch = FetchType.LAZY) private XincoWorkflow xincoWorkflow; Notice the added userLinkId reference. See attachments for sql and db schema for reproduction. This have been seen in dev. builds as well.
Created attachment 93392 [details] SQL to recreate the database.
The correct modification is as follows: @JoinColumns({ @JoinColumn(name = "xinco_workflow_id", referencedColumnName = "id", nullable = false, insertable = false, updatable = false), @JoinColumn(name = "xinco_workflow_id", referencedColumnName = "xincoWorkflowId", nullable = false, insertable = false, updatable = false), @JoinColumn(name = "xinco_workflow_version", referencedColumnName = "version", nullable = false, insertable = false, updatable = false)}) @ManyToOne(optional = false, fetch = FetchType.LAZY) private XincoWorkflow xincoWorkflow;
where is this error was produced? was it a message from eclipselink? for me looks strange to have to references with the same name to different columns in one JoinColumns: @JoinColumn(name = "xinco_workflow_id", referencedColumnName = "id", nullable = false, insertable = false, updatable = false), @JoinColumn(name = "xinco_workflow_id", referencedColumnName = "xincoWorkflowId", nullable = false, insertable = false, updatable = false) also initial generation match table declaration with CONSTRAINT `fk_xinco_state_xinco_workflow1` FOREIGN KEY (`xinco_workflow_id` , `xinco_workflow_version` ) REFERENCES `xinco_workflow`.`xinco_workflow` (`id` , `version` ) Am I miss something? Why third @JoinColumn is required?
The third column is due to a composite primary key. The generated class is missing half of the key (1 out of 2). If I'm correct one relationship is for another table and there's one to the entity itself.
Ok, I see the problem if try to deploy web project. Message from toplink is javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException Exception Description: predeploy for PersistenceUnit [WebApplication4PU] failed. Internal Exception: Exception [TOPLINK-7220] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.ValidationException Exception Description: The @JoinColumns on the annotated element [private e.XincoWorkflow e.XincoWorkflowState.xincoWorkflow] from the entity class [class e.XincoWorkflowState] 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 referenceColumnName elements must be specified in each such @JoinColumn. at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:643) from EclipselInk: Internal Exception: Exception [EclipseLink-7220] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.ValidationException Exception Description: The @JoinColumns on the annotated element [field xincoWorkflow] from the entity class [class e.XincoWorkflowState] 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. at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:210) ... 34 more Caused by: Exception [EclipseLink-7220] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.ValidationException Exception Description: The @JoinColumns on the annotated element [field xincoWorkflow] from the entity class [class e.XincoWorkflowState] 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. at org.eclipse.persistence.exceptions.ValidationException.incompleteJoinColumnsSpecified(ValidationException.java:1808)
As sql maps only two from three columns in foreign key to primary key, this behaior seems to be expected and require some special handling, fas in general may not be supported by toplink/eclipselink etc and if will be supported may not be portable. Some workaround may be created, but may be it's hard to request such workarounds from nb or it should be some enhancment then. see http://forums.oracle.com/forums/thread.jspa?threadID=448956 for example. Your workaround seems to fix to pass validation rules but I don't see it match initial sql script.
> Enhancment Current realization create 1-1 map from tables to entities, resulting relations may not fit in required support from providers, for example support for imcomplete maps is optional. It may be good to find a way to workaround such cases or to add warning from nb so user will get warning from nb instead of runtime problem.
This issue is still present on 6.9.1
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue. Thanks for your cooperation, NetBeans IDE 8.2 Release Boss