Hibernate CriteriaBuilder联接两个表

时间:2019-01-12 08:42:18

标签: hibernate

我可以使用CriteriaBuilder联接2个表吗?

以下是表格:

@Entity
public class People {
@Id
@GenerateValue
private Integer id;
private String Name;
}

@Entity
public class Phone {
@Id
@GeneratedValue
private Integer id;
private String PhoneNumber;
@ManyToOne
@JoinColumn(name = "people_id")
private People people;

如何使用Hibernate CriteriaBuilder实现以下查询?

select * from People b1 inner join Phone b2 on b1.id = b2.people_id where b2.PhoneNumber = xxxxxx;

0 个答案:

没有答案