`
antivir
  • 浏览: 95278 次
  • 来自: ...
社区版块
存档分类
最新评论

将多表中的多个字段映射到一个DTO

 
阅读更多

public class ADTO
{
    public ADTO(String a,String b){
        this.apname=a;
        this.apname=b;
    }
   
    String prcode;
    String apname;
    public String getApname()
    {
        return apname;
    }
    public void setApname(
        String apname)
    {
        this.apname = apname;
    }
    public String getPrcode()
    {
        return prcode;
    }
    public void setPrcode(
        String prcode)
    {
        this.prcode = prcode;
    }
}

 

public static void main(
        String[] args)
        throws Exception
    {
        Session session = SessionManager.getNewSession();

        String hql = "select new test.ADTO(a.prcode,b.apname) " +
                "from com.life.persistence.policy.group.GpyPlan a,com.life.persistence.policy.group.GpyPoli b where a.policyno=b.id and b.polists='01' and b.id like '998%'";
        List list=session.createQuery(hql).list();
        System.out.println(list.size());
        System.out.println(list.get(0).getClass().getName());
        ADTO adto=(ADTO)list.get(0);
    }

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics