Hello,
I'm trying to set up a primary key which also is an foreign key.
Consider the following example:
Code:
@Entity
public class Person {
  private Long personID;
  
  @Id
  public Long getPersonID() {
    return personID;
  }
  public void setPersonID(Long id) {
    this.personID = id;
  }
}
And the class where personID should be both primary and foreign key:
Code:
@Entity
public class PersonData {
  private Person person;
  @Id
  @ManyToOne
  @JoinColumn(name="personID")
  public Person getPerson() {
    return person;
  }
...
}
In the DB in table PersonData the field isn't named personID but person. It's not a foreign key, it's a simple varbinary.
What is wrong in the above code?
Thanks,
Kasperl