[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-4987) SecondaryTable JoinColumn cannot reference a non primary key
lelmarir (JIRA)
noreply at atlassian.com
Mon Feb 13 11:27:10 EST 2012
[ https://hibernate.onjira.com/browse/HHH-4987?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45504#comment-45504 ]
lelmarir commented on HHH-4987:
-------------------------------
I also have this problem with hibernate 4
> SecondaryTable JoinColumn cannot reference a non primary key
> ------------------------------------------------------------
>
> Key: HHH-4987
> URL: https://hibernate.onjira.com/browse/HHH-4987
> Project: Hibernate ORM
> Issue Type: Bug
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list