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.
In the spec: 2.4.1 Primary Keys Corresponding to Derived Identities The identity of an entity may be derived from the identity of another entity (the "parent" entity) when the former entity (the "dependent" entity) is the owner of a many-to-one or one-to-one relationship to the parent entity and a foreign key maps the relationship from dependent to parent. For example, in the attached ERD, consider the aspectDisplay table. "Enitty Classes from Database" generates something like: @Entity @Table(name = "ASPECTDISPLAY", catalog = "", schema = "ERNIE") public class Aspectdisplay implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId protected AspectdisplayPK aspectdisplayPK; @Basic(optional = false) @Lob @Column(name = "DAT", nullable = false) private Serializable dat; @JoinColumns({@JoinColumn(name = "CHART_ID", referencedColumnName = "CHART_ID", nullable = false, insertable = false, updatable = false), @JoinColumn(name = "EVENT_ID", referencedColumnName = "EVENT_ID", nullable = false, insertable = false, updatable = false)}) @OneToOne(optional = false) private ChartEvent chartEvent; wheras instead of using @JoinColumns, it should be done with @MappedById. @Entity @Table(name = "ASPECTDISPLAY", catalog = "", schema = "ERNIE") public class Aspectdisplay implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId protected ChartEventPK chartEventPK; @Basic(optional = false) @Lob @Column(name = "DAT", nullable = false) private Serializable dat; @MappedById // <<<<<<<<<<<<<<<<<<<<<<< instead of @JoinColumns @OneToOne(optional = false) private ChartEvent chartEvent; Mapping this way allows the persistence provider to automatically set the primary key (chartEvent must be set). (Note in the JPA 1.0 release this should be mapped with @PrimaryKeyJoinColumns, @MappedById is now the preferred mechanism) This is loosely related to Issue 172075, but there is no dependency.
Created attachment 88561 [details] ERD showing relationship at issue
looks like enhancement of feature for better support new features from jpa 2.0, it's closely correlate with initial plan for 6.8, but it seems it will not be implemented in 6.8.
> > Note in the JPA 1.0 release this should be mapped with @PrimaryKeyJoinColumns, > > @MappedById is now the preferred mechanism > enhancement of feature for better support new features from jpa 2.0 Looks like this was an issue with the JPA 1.0 support as well; since there is a mapping specifically for "primary key column that is used as a foreign key to join to another table". However, I understand that there probably is not time to get it into 6.8; I'm just really glad I found it, it was driving me nuts not being able to specify this in the mappings.
also if we are talking about derived identifiers, it seems this area isn't final yet in jpa 2.0 specification.