3

我对 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])

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

谢谢你的帮助!!

4

1 回答 1

0

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

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 
于 2009-05-18T02:41:36.913 回答