org.hibernate.AnnotationException: SecondaryTable JoinColumn cannot reference a non primary key

Hibernate JIRA | Krashan Brahmanjara | 7 years ago
  1. 0

    [HHH-4987] SecondaryTable JoinColumn cannot reference a non primary key - Hibernate JIRA

    atlassian.net | 1 year ago
    org.hibernate.AnnotationException: SecondaryTable JoinColumn cannot reference a non primary key
  2. 0

    Hibertate annotations reject correct annotations with an error Full exception org.hibernate.AnnotationException: SecondaryTable JoinColumn cannot reference a non primary key at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:243) at org.hibernate.cfg.annotations.EntityBinder.bindJoinToPersistentClass(EntityBinder.java:520) at org.hibernate.cfg.annotations.EntityBinder.createPrimaryColumnsToSecondaryTable(EntityBinder.java:510) at org.hibernate.cfg.annotations.EntityBinder.finalSecondaryTableBinding(EntityBinder.java:441) at org.hibernate.cfg.SecondaryTableSecondPass.doSecondPass(SecondaryTableSecondPass.java:25) Example Three entity, two connected to main 'dokument' by their id columns @Entity @Table(name = "dokument") @SecondaryTables(value = { @SecondaryTable(name = "dokument_status", pkJoinColumns = @PrimaryKeyJoinColumn(name = "id_status", referencedColumnName = "id_status")), @SecondaryTable(name = "typ_dok", pkJoinColumns = @PrimaryKeyJoinColumn(name = "id_type", referencedColumnName = "id_type")) }) public class PosrDokument implements Serializable { @Id @Column(name="id_dokumentu", unique=true, nullable=false) private int id_dokumentu; @Column(name = "status", table = "dokument_status", nullable = false, insertable = false, updatable = false) private String status; @Column(name = "name", table = "typ_dok", nullable = false, insertable = false, updatable = false) private String name; (...)

    Hibernate JIRA | 7 years ago | Krashan Brahmanjara
    org.hibernate.AnnotationException: SecondaryTable JoinColumn cannot reference a non primary key
  3. 0

    Hibertate annotations reject correct annotations with an error Full exception org.hibernate.AnnotationException: SecondaryTable JoinColumn cannot reference a non primary key at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:243) at org.hibernate.cfg.annotations.EntityBinder.bindJoinToPersistentClass(EntityBinder.java:520) at org.hibernate.cfg.annotations.EntityBinder.createPrimaryColumnsToSecondaryTable(EntityBinder.java:510) at org.hibernate.cfg.annotations.EntityBinder.finalSecondaryTableBinding(EntityBinder.java:441) at org.hibernate.cfg.SecondaryTableSecondPass.doSecondPass(SecondaryTableSecondPass.java:25) Example Three entity, two connected to main 'dokument' by their id columns @Entity @Table(name = "dokument") @SecondaryTables(value = { @SecondaryTable(name = "dokument_status", pkJoinColumns = @PrimaryKeyJoinColumn(name = "id_status", referencedColumnName = "id_status")), @SecondaryTable(name = "typ_dok", pkJoinColumns = @PrimaryKeyJoinColumn(name = "id_type", referencedColumnName = "id_type")) }) public class PosrDokument implements Serializable { @Id @Column(name="id_dokumentu", unique=true, nullable=false) private int id_dokumentu; @Column(name = "status", table = "dokument_status", nullable = false, insertable = false, updatable = false) private String status; @Column(name = "name", table = "typ_dok", nullable = false, insertable = false, updatable = false) private String name; (...)

    Hibernate JIRA | 7 years ago | Krashan Brahmanjara
    org.hibernate.AnnotationException: SecondaryTable JoinColumn cannot reference a non primary key
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    JPA fetching value from Many to One relationship

    Stack Overflow | 1 year ago | Juriy
    org.hibernate.AnnotationException: SecondaryTable JoinColumn cannot reference a non primary key
  6. 0

    JPA doesn't t allow entity made of columns from multiple tables?

    Stack Overflow | 4 years ago | zx_wing
    org.hibernate.AnnotationException: SecondaryTable JoinColumn cannot reference a non primary key

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.AnnotationException

      SecondaryTable JoinColumn cannot reference a non primary key

      at org.hibernate.cfg.annotations.TableBinder.bindFk()
    2. Hibernate
      SecondaryTableSecondPass.doSecondPass
      1. org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:243)
      2. org.hibernate.cfg.annotations.EntityBinder.bindJoinToPersistentClass(EntityBinder.java:520)
      3. org.hibernate.cfg.annotations.EntityBinder.createPrimaryColumnsToSecondaryTable(EntityBinder.java:510)
      4. org.hibernate.cfg.annotations.EntityBinder.finalSecondaryTableBinding(EntityBinder.java:441)
      5. org.hibernate.cfg.SecondaryTableSecondPass.doSecondPass(SecondaryTableSecondPass.java:25)
      5 frames