代码之家  ›  专栏  ›  技术社区  ›  Thomas Bratt

如何将注释放入HQL(Hibernate查询语言)中?

  •  10
  • Thomas Bratt  · 技术社区  · 16 年前

    3 回复  |  直到 16 年前
        1
  •  10
  •   nsmyself    16 年前

    AFAIK,HQL不支持注释。

        2
  •  23
  •   Hisham    16 年前

    确保会话配置为:

    
    <property name="hibernate.use_sql_comments">true</property>
    
    

    然后做:

    
    Query query = ...;
    query.setComment("Some comment here");
    
    

    
    5998 Query /* Some comment here */ select .....
    
    
        3
  •  0
  •   Kawu    15 年前

    如果有助于您的开发,Hibernate工具(Eclipse)在HQL编辑器中支持双连字符作为单行注释。对我帮助很大。我刚刚尝试了JPQL语句

    SELECT pro --ro.id, cl.name, te.ordinalNbr, tt.code, se.startYear, pro.id, pcl.name, pte.ordinalNbr, ptt.code, pse.startYear
    FROM Roster ro
      JOIN ro.season se
      JOIN ro.team te
      JOIN te.club cl
      JOIN te.teamType tt
      JOIN te.rosters pro
      JOIN pro.season pse
      JOIN pro.team pte
      JOIN pte.club pcl
      JOIN pte.teamType ptt
    WHERE ro.id = 32
    ORDER BY pse.startYear
    

    也不太切题,但它可能是有用的。

    推荐文章