How to map a @ManyToOne association using a non-Primary Key in Hibernate?
I can use a @NaturalId annotation, but sill have a error:
A Foreign key refering POJO.Question from POJO.Answer has the wrong number of column. should be 4
Question class (with multiple primary key):
    @Entity
    @Table(name = "[dbo].[Question]")
    public class Question implements Serializable {
        @Column(name = "[Id]", unique = true, nullable = false) 
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @NaturalId
        private Integer id;
        @EmbeddedId
        private QuestionEmbeddable questionEmbeddable;
}
Primary key
    public class QuestionEmbeddable implements Serializable{
        @Column(name = "[Development Template Id]")
        private int templateId;
        //Sekcja w templejcie
        @Column(name = "[Section]")
        private Integer section;
        //Numer w sekcji
        @Column(name = "[Number]")
        private Integer number;
        //Wersja 
        @Column(name = "[Version]")
        private Integer version;
}
Answer class:
    @Entity
    @Table(name = "[dbo].[Answer]")
    public class Answer implements Serializable {
        @Id
        @Column(name = "[Id]", unique = true, nullable = false) 
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private Integer id;
        @JoinColumn(name = "[Question Id]")
        @ManyToOne(fetch=FetchType.LAZY)
        private Question question;
It looks like the association is still to @EmbeddedId instead of @Naturalid. I don't know why?
 
    