我有2个实体 黑名单标准休眠
public class BlackList {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", unique = true, nullable = false)
private Integer id;
@ManyToOne
@JoinColumn(name = "applicant_id", unique = true)
private Applicant applicant;
和
public class Applicant {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", unique = true, nullable = false)
private Integer id;
@Column(name = "number", nullable = false, unique = true)
private String number;
请帮助我。如何创建标准得到我的数据的查询:select applicant.number from black_list inner join applicant on black_list.applicant_id = applicant.id
public List<BlackList> getAll(){
Session session =sessionFactory.getCurrentSession();
ProjectionList projectionList = Projections.projectionList();
Criteria criteria = session.createCriteria(BlackList.class);
projectionList.add(Projections.property("applicant"));
criteria.setProjection(projectionList);
List res = criteria.list();
return res;
}
此方法返回ME/ID和数字/但我只需要数
,我们可以帮我写这个? –