zoukankan      html  css  js  c++  java
  • hql实现select new Type(column) from table

    string query1 = "select MAX(g.Stars) ,

    new AuthorDTO(MAX(cast(g.GroupName as string))//不知道为什么不能加在聚合函数里面,也不能加到Group

    from Group g join g.authors auths group by g.GroupName";

    下面方式可以:

    string query1 = "select g.Stars,

    new AuthorDTO(cast(g.GroupName as string)//需要在Group.hbm.xml里面添加<import class="Gx.DTO.AuthorDTO,Gx.DTO"></import>,参考下面的xml

    //new Group(cast(g.GroupName as string)

    from Group g join g.authors auths group by g.GroupName";

    <?xml version="1.0" encoding="utf-8" ?>
    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">

    <import class="Gx.DTO.AuthorDTO,Gx.DTO"></import>
    <class name="Entity.UpFileView, Entity" table="UpFileView">
    <id name="Fid" column="Fid" type="Int32">
    <generator class="identity" />
    </id>

  • 相关阅读:
    2-7
    2-6
    2-5
    2-4
    2-3
    2-1
    2-2
    1-1
    5-7
    第六章例6-1
  • 原文地址:https://www.cnblogs.com/zhuhoumo/p/2837668.html
Copyright © 2011-2022 走看看