在下面的代码中.. 有两个别名作为Entity Object
参考。有时"caseStage" as stage
可以null
在数据库中。什么时候"caseStage"
为空,我希望stage.name
值为空String
或自定义的值等"---"
。
session.createCriteria(CaseMasterPO.class)
.createAlias("branch", "br") // BranchPO.class
.createAlias("caseStage", "stage") // CaseStagePO.class
.setProjection(Projections.projectionList()
.add(Projections.property("caseCode"))
.add(Projections.property("br.zoneCode"))
.add(Projections.property("stage.name")) // Problem, when stage == null
)
.add(Restrictions.eq("caseCode", caseCode)).uniqueResult();