J'ai 2 entité BlackListCritères de se joindre à deux tables Hibernate
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;
et
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;
s'il vous plaît aidez-moi. Comment créer des critères pour moi d'obtenir des données pour cette requête: 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;
}
cette méthode me retourne/id et le numéro/mais j'ai besoin seul numéro
pourrait-on me aider à écrire cela? –