【问题标题】:HQL: order all items by a specific item in its mapHQL:按其地图中的特定项目对所有项目进行排序
【发布时间】:2009-05-15 08:14:03
【问题描述】:

我对 Hibernate 还很陌生,目前在 HQL 方面有点挣扎。我有以下映射,并希望获取给定“culture_id”的“翻译”排序的所有“行业”实体

代码:

  <?xml version="1.0" encoding="utf-8" ?>
  <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="Domain.Industry, Core" table="industry">

    <id name="ID" unsaved-value="0">
      <generator class="identity" />
    </id>

    <map name="AllNames"
      access="nosetter.camelcase-underscore"
      table="_dict_industry_name"
      cascade="all-delete-orphan">
      <key column="record_id"></key>
      <index column="culture_id" type="Int32"></index>
      <element column="translation" type="String"></element>
    </map>

  </class>
  </hibernate-mapping>

我尝试了以下方法: 代码:

from Industry industry order by elements(industry.AllNames[:lcid])

但它不起作用......

感谢您的帮助!!

【问题讨论】:

    标签: nhibernate hibernate hql


    【解决方案1】:

    由于没有发布答案,我已在其他一些论坛中询问过。以下是两种可能的解决方案:

    https://forum.hibernate.org/viewtopic.php?f=1&t=996853

    http://groups.google.com/group/nhusers/browse_thread/thread/1750d64ecdeb72f9

    我更喜欢这个:

    from Industry industry
    where index(industry) = :lcid
    order by industry.AllNames 
    

    【讨论】:

      猜你喜欢
      • 2022-01-26
      • 1970-01-01
      • 2011-05-16
      • 2018-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-27
      • 1970-01-01
      相关资源
      最近更新 更多