Hibernate联接2个表的条件

时间:2018-10-31 07:21:05

标签: java hibernate criteria

我在以下实体中有2个表:

@Entity
@Table(name = "CLAIM")
@AutoProperty
public class Claim {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_request")
@SequenceGenerator(name = "id_request", sequenceName = "CLAIM_SEQ")
private Long id;

@Column(name = "CLAIM_MEP_ID")
private Long claimMepId;

================================================ =======================

@Entity
@Table(name = "MEP")
@AutoProperty
public class Mep {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_mep")
@SequenceGenerator(name = "id_mep", sequenceName = "MEP_SEQ")
private Long id;

我想用Claim.claimMepId = mep.id联接表

Criteria cr = session.createCriteria(Claim.class);
ClaimStatus st = ClaimStatus.valueOf(status.toUpperCase());
cr.add(Restrictions.eq("status", st));
List<Claim> listClaims = cr.list();

我试图创建一个别名并使用投影,但是我总是收到错误“是要求的财产” 任何帮助表示赞赏。

0 个答案:

没有答案