cancel
Showing results for 
Search instead for 
Did you mean: 

@PrimaryKeyJoinColumn supported?

Former Member
0 Kudos

Hi,

my domain snippet:


@Entity
@Table(name = "EIC_SHAREDS")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "DTYPE", discriminatorType = DiscriminatorType.STRING, length = 1)
public abstract class AbstractSharedDataset implements SharedDataset, Serializable {

  @Id
  @GeneratedValue
  @Column(name = "SHARED_ID")
  private long id;

  @OneToOne(optional = false, cascade = CascadeType.ALL)
  @PrimaryKeyJoinColumn(name = "SHARED_ID", referencedColumnName = "HOLDER_ID")
  private DatasetImpl dataset;

translates correctly into a table with two columns ...

but persisting doesn't work due to this obvious error:

Caused by: com.sap.sql.log.OpenSQLException: The SQL statement "INSERT INTO "EIC_SHAREDS" ("SHARED_ID","SHARED_ID","DTYPE") VALUES (?,?,'A')" contains the semantics error[s]: - 1:40 - column ""SHARED_ID"" not unique

So I'm asking myself whether @PrimaryKeyJoinColumn is supported ...

I tried already to mark the id as not insertable, which translates in the following try:

Caused by: com.sap.sql.log.OpenSQLException: The SQL statement "INSERT INTO "EIC_SHAREDS" ("DTYPE") VALUES ( 'A') " contains the semantics error[s]: - the column "SHARED_ID" of the table "EIC_SHAREDS", which is not nullable and has no default, is missing in the insert column list

This might work, if I knew how to teach MaxDB to generate the id on its own ...

Thankyou for some information on that

Edited by: konrad.krentz on Nov 18, 2009 12:02 PM

Edited by: konrad.krentz on Nov 18, 2009 12:06 PM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

i marked the referenced column as well as the original column with that:

Exception of type com.sap.sql.log.OpenSQLException caught: The SQL statement "INSERT INTO "EIC_SHAREDS" ("DTYPE") VALUES ( 'G') " contains the semantics error[s]: - the column "SHARED_ID" of the table "EIC_SHAREDS", which is not nullable and has no default, is missing in the insert column list

But these attributes are not available on @PrimaryKeyJoinColumn if you meant that

adrian_goerler
Active Participant
0 Kudos

Hi Konrad,

please try marking the primary key join column as insertable=false, updatable=false.

-Adrian

Edited by: Adrian Goerler on Nov 18, 2009 1:07 PM