我可以使用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;