[hibernate-issues] [Hibernate-JIRA] Created: (HCANN-17) SecondaryTable JoinColumn cannot reference a non primary key

Krashan Brahmanjara (JIRA) noreply at atlassian.com
Thu Feb 25 10:33:47 EST 2010


SecondaryTable JoinColumn cannot reference a non primary key
------------------------------------------------------------

                 Key: HCANN-17
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HCANN-17
             Project: Hibernate Commons Annotations
          Issue Type: Bug
    Affects Versions: 3.1.0.GA
         Environment: Hibernate libraries added to jboss-6.0.0.20100216-M2(3.5) and jboss-5.1.0.GA(3.3.1) used with postgresql-8.3.7-1 database and jdbc driver postgresql-8.3-603.jdbc4.jar
            Reporter: Krashan Brahmanjara


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;
(...)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list