Хотя я провел небольшое исследование по этому вопросу и обнаружил множество угроз, открытых в Интернете, я не смог решить свою проблему. Я прилагаю свой код:
Triple.java первичный ключ состоит из трех URI из трех разных концепций, но это один и тот же столбец (это проблема?)
@Entity
@IdClass(ConceptPk.class)
@Table(name = "triple")
public class TripleDBModel {
protected List<Annotation> annotations;
public String conceptUriSubject;
public String conceptUriObject;
public String conceptUriPredicate;
public String id;
@ManyToMany(
cascade={CascadeType.ALL},
fetch=FetchType.LAZY
)
@JoinTable(name = "triple_has_annotation",
joinColumns=@JoinColumn(name="annotation_id"),
inverseJoinColumns={@JoinColumn(name="uri_concept_subject", referencedColumnName="triple_id"), @JoinColumn(name="uri_concept_object", referencedColumnName="triple_id"), @JoinColumn(name="uri_concept_predicate", referencedColumnName="triple_id")
})//EDIT
public List<Annotation> getAnnotations() {
return annotations;
}
public void setAnnotations(List<Annotation> annotations) {
this.annotations = annotations;
}
@Id
@Column(name = "uri_concept_subject", length = 100)
public String getConceptUriSubject() {
return conceptUriSubject;
}
public void setConceptUriSubject(String conceptUriSubject) {
this.conceptUriSubject = conceptUriSubject;
}
@Id
@Column(name = "uri_concept_object", length = 100)
public String getConceptUriObject() {
return conceptUriObject;
}
public void setConceptUriObject(String conceptUriObject) {
this.conceptUriObject = conceptUriObject;
}
@Id
@Column(name = "uri_concept_predicate", length = 100)
public String getConceptUriPredicate() {
return conceptUriPredicate;
}
public void setConceptUriPredicate(String conceptUriPredicate) {
this.conceptUriPredicate = conceptUriPredicate;
}
@Id
@Column(name = "triple_id", unique = true, nullable = false)
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
ConceptPk.java
@Embeddable
public class ConceptPk implements java.io.Serializable {
private static final long serialVersionUID = 1L;
public String conceptUriSubject;
public String conceptUriObject;
public String conceptUriPredicate;
@Id
@Column(name = "uri", length = 100, unique = true, nullable = false)
public String getConceptUriSubject() {
return conceptUriSubject;
}
public void setConceptUriSubject(String conceptUriSubject) {
this.conceptUriSubject = conceptUriSubject;
}
@Id
@Column(name = "uri", length = 100, unique = true, nullable = false)
public String getConceptUriObject() {
return conceptUriObject;
}
public void setConceptUriObject(String conceptUriObject) {
this.conceptUriObject = conceptUriObject;
}
@Id
@Column(name = "uri", length = 100, unique = true, nullable = false)
public String getConceptUriPredicate() {
return conceptUriPredicate;
}
public void setConceptUriPredicate(String conceptUriPredicate) {
this.conceptUriPredicate = conceptUriPredicate;
}
Аннотация.java
@Entity
@Table(name = "annotations")
public class Annotation {
private Integer id;
private List<TripleDBModel> triples;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "annotation_id", unique = true, nullable = false)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@ManyToMany(
cascade={CascadeType.ALL},
mappedBy = "annotations", //EDIT
fetch=FetchType.LAZY
)
public List<TripleDBModel> getTriples() {
return triples;
}
public void setTriples(List<TripleDBModel> triples) {
this.triples = triples;
}
Но я получаю эту ошибку:
Caused by: org.hibernate.AnnotationException: A Foreign key refering TripleDBModel from Annotation has the wrong number of column. should be 3
Что я делаю не так ?? Заранее спасибо