私は次のようなテーブル構造を持っています.1対多と多対1が複合キーの1つにマップされています。
@Entity
@Table(name = "parent", catalog = "testdb")
public class Parent implements java.io.Serializable {
private Long fileId;
private Set<Children> children = new HashSet<Children>();
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "file_id", unique = true, nullable = false)
public Long getFileId() {
return this.fileId;
}
public void setFileId(Long fileId) {
this.fileId = fileId;
}
@OneToMany(mappedBy = "id.childrenIc")
public Set<Children> getChildren() {
return children;
}
public void setChildren(Set<Children> children) {
this.children= children;
}
}
@Entity
@Table(name = "children", catalog = "testdb")
public class Children implements java.io.Serializable {
private ChildrenId id;
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "childId", column = @Column(name = "child_id", nullable = false)),
@AttributeOverride(name = "childrenIc", column = @Column(name = "child_ic", nullable = false)) })
public ChildrenId getId () {
return this.id;
}
public void setId(ChildrenId id) {
this.id = id;
}
}
@Embeddable
public class ChildrenId implements java.io.Serializable {
private long childId;
private Children childIc;
@ManyToOne
public Children getChildIc() {
return childIc;
}
public void setChildIc(Children childIc) {
this.childIc= childIc;
}
@Column(name = "child_id", nullable = false)
public long getChildId() {
return this.childId;
}
public void setChildId(long childId) {
this.childId= childId;
}
}
Criteria criteria = session.createCriteria(Parents.class);
Criteria childCri = criteria.createCriteria("childrenIc");
childCri .add(Restrictions.eq("childId", childId));
条件を使用してテーブルを結合しようとすると失敗します。'where 句' org.hibernate.exception.SQLGrammarException の不明な列 'this_.childrenIc_child_id': クエリを実行できませんでした
私も変えました
Criteria childCri = criteria.createCriteria("id.childrenIc");
それも失敗します。
助けてください、ありがとう。