I'm trying to use @SecondaryTable, hoping to join from a foreign key on my p

I'm trying to use @SecondaryTable, hoping to join from a foreign key on my primary table to the primary key on the secondary table. However it seems to ignore my referencedColumn annotation and joins to the primary key of my primary table. Is it not possible to use @SecondaryTable with something other than the primary key of the primary table?

DOC_TABLE:
DOC_ID (pk)
TYPE_ID (fk to LOOKUP_ID of LOOKUP table)

LOOKUP_TABLE:
LOOKUP_ID (pk)
DOMAIN_VALUE (field I want to show in my CDT).

CDT mapping:
<xsd:complexType name="TAX_Doc">
<xsd:annotation>
<xsd:appinfo source="appian.jpa">
@Table(name="DOC_TABLE")
@SecondaryTable(name="LOOKUP_TABLE", pkJoinColumns=@PrimaryKeyJoinColumn(name="LOOKUP_ID", referencedColumnName="TYPE_ID"))
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="id" type="xsd:int">
<xsd:annotation>
<xsd:appinfo source="appian.jpa">
@Column(name="DOC_ID", nullable=false)
...

OriginalPostID-81009

OriginalPostID-81009

  Discussion posts and replies are publicly visible

Parents
  • @peterh, To my knowledge, @SecondaryTable can't be used for mapping non-primary key columns. And the reason why referencedColumn is ignored could be, when @SecondaryTable doesn't find any primary key join columns or a non-matching column (i.e. not the same column as Primary Key of the Primary Table), maps to primary key of the primary table. I think you have to go for a work around if you still want mappings to non-primary keys of the primary table.
Reply
  • @peterh, To my knowledge, @SecondaryTable can't be used for mapping non-primary key columns. And the reason why referencedColumn is ignored could be, when @SecondaryTable doesn't find any primary key join columns or a non-matching column (i.e. not the same column as Primary Key of the Primary Table), maps to primary key of the primary table. I think you have to go for a work around if you still want mappings to non-primary keys of the primary table.
Children
No Data