我有两个实体
@Entity
@Table(name="one")
public class One implements Serializable {
@Id
@NotNull
@Column(name = "id")
private String id;
@Column(name = "name")
private String name;
@Column(name = "title")
private String title;
@ManyToOne
@JoinColumn(name = "three_id")
private Three three;
}
@Entity
@Table(name="two")
public class Two implements Serializable {
@Id
@NotNull
@Column(name = "id")
private String id;
@Column(name = "order")
private String order;
@ManyToOne
@JoinColumn(name = "three_id")
private Three three;
}
@Entity
@Table(name="three")
public class Three implements Serializable {
@Id
@NotNull
@Column(name = "id")
private String id;
@Column(name = "quantity")
private String quantity;
}
并将命名查询作为
select o.name from one o, two tw, three th where tw.order="test" and o.three.id = tw.three.id;
部署此org.hibernate.HibernateException: Errors in named queries
目的是我想要基于公共列three_id的两个表中的行,这是表#34中的id字段;三个" 为什么会失败,我该如何解决这个问题。
答案 0 :(得分:0)
好吧,似乎你在查询中的任何地方都没有使用它,可能是问题。
这应该有效:
从一个o,两个tw中选择o.name,其中tw.order =" test"和o.three.id = tw.three.id;