Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Join inheritance type and composite primary keys

bytec0deFeb 1 2007 — edited Feb 7 2007
Hi,

I'm having trouble in defining a joined inheritance relationship with composite keys. I'm using glassfish v2 b25 and PostgreSQL 8.1.

My first unsuccessfully attempt was:
---------------
@Entity
@Inheritance(strategy = InheritanceType.JOINED )
public class Parent {
@Id
@Column(name="ID")
protected long id;

@Id
@Column(name="NAME", nullable=false)
protected String name;

public Parent() {
}
}

@Entity
public class Child extends Parent {
@Lob
private String summaryText;

public Child() {
}
}
-----

Deploy fails with the following error:
"Exception Description: An incomplete @PrimaryKeyJoinColumns was specified on the annotated element [class test.Child]. When specifying @PrimaryKeyJoinColumns for an entity that has a composite primary key, a @PrimaryKeyJoinColumn must be specified for each primary key join column using the @PrimaryKeyJoinColumns. Both the name and the referenceColumnName elements must be specified in each such @PrimaryKeyJoinColumn."

Then I change the Child class and added the @PrimaryKeyJoinColumns annotation:
-----
@Entity
@PrimaryKeyJoinColumns({
@PrimaryKeyJoinColumn(name="ID", referencedColumnName="ID"),
@PrimaryKeyJoinColumn(name="LOCALE", referencedColumnName="LOCALE")
})
public class Child extends Parent {
@Lob
private String summaryText;

public Child() {
}
}

But has expected deploy fails with the following error:
JDO76609: Got SQLException executing statement "ALTER TABLE CHILD ADD CONSTRAINT FK_CHILD_LOCALE FOREIGN KEY (LOCALE, ID) REFERENCES PARENT (LOCALE, ID)": org.postgresql.util.PSQLException: ERROR: there is no unique constraint matching given keys for referenced table "parent"

Any idea how to solve the problem?

Thanx

Vitor Carreira
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 7 2007
Added on Feb 1 2007
3 comments
2,099 views