我有下面的pojo,我必须为以下sql生成hql或标准..
class took
{
private String aaa;
private String bbb = "";
private String ccc;
public took(String aaa, String bbb ,String ccc)
{
this.aaa = aaa;
this.bbb = bbb;
this.ccc = ccc;
}
}
SELECT aaa,DECODE(bbb_b,'Y','Act','Rev') as perm,ccc_c FROM took
我也为此生成了HQL,如下所示,但是这个查询的问题是,如上面的sql查询所示,我在列bbb_b上使用DECODE并设置它值加上此列perm是动态创建的这个查询本身如何在hql本身中调整它 请指教。
List<took> b1 = session.createQuery("select new com.abc.def.took(aaa, bbb,ccc) from took").list();
请告知本文等同的crtiteria
答案 0 :(得分:0)
您可以将此注释添加到bbb属性中(如果使用注释)。
@Formula("DECODE(bbb_b,'Y','Act','Rev')")
public String getBbb() {
return bbb;
}