]
Michel Domenjoud commented on HHH-4987:
---------------------------------------
Hello,
we encounter the same issue using 3.5.4.
Could this issue come from the fact we are testing our application with HSQL and we
delegate the DB schema creation to discover by annotations?
Maybe the automatic parse of the annotations is unable to create the secondary table with
the primary key attribute?
Thanks by advance for your answer.
SecondaryTable JoinColumn cannot reference a non primary key
------------------------------------------------------------
Key: HHH-4987
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4987
Project: Hibernate Core
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.
-
If you think it was sent incorrectly contact one of the administrators: