我需要将以下查询转换为休眠 -
select * from ep_batch eb
INNER JOIN ep_slide slide ON eb.batch_scanner_id = slide.slide_batch_id
WHERE eb.batch_scanner_id = 1 AND
eb.batch_status =
(
IF((SELECT count(batch_id) as cnt from ep_batch WHERE batch_scanner_id = 1) =1,'Ready','In Progress')
) ;
我确实有“幻灯片”和“批处理”pojo 分别代表 ep_slide 和 ep_batch。加入注释为 -
@OneToMany(mappedBy = "batch")
private Set<Slide> slides;
@ManyToOne
@JoinColumn(name = "batchId")
private Batch batch;
我不太确定如何添加带有条件的子查询。我正在尝试类似下面的东西 -
DetachedCriteria subCriteria = DetachedCriteria.forClass(Slide.class);
subCriteria.setProjection(Projections.count("batchId"));