1

I use a base entity class for all my entities. It maps to a table that contains columns shared by all entities.

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="entpcd",   discriminatorType=DiscriminatorType.STRING)
@Table(name="enrg")
public abstract class BaseEntity

@Id
@Column(name="enid")
private String entityId=null;

And I have an entity class that represents a Person, mapped to its own table.

@Entity
@DiscriminatorValue("PN")
@Table(name="pn")
public class Person extends BaseEntity

ENRG table structure

enid, col2, col3

PN table structure

pnid, col2 col3

While retrieving a Person, Hibernate fails trying to do a join on enrg.enid=pn.enid. How do I override id mapping in Person to have Hibernate join on enrg.enid=pn.pnid?

jacekn
  • 1,521
  • 5
  • 29
  • 50

1 Answers1

1

@PrimaryKeyJoinColumn(name="pnid") solves the problem.

From what I'm reading, Hibernate is having issues with @AttributeOverride on id columns. More -> https://forum.hibernate.org/viewtopic.php?f=1&t=990510

jacekn
  • 1,521
  • 5
  • 29
  • 50