HQL: sort all elements by a specific element on their map

I am new to Hibernate and am currently struggling a bit with HQL. I have the following comparison and would like to get all the "industrial" entities ordered by the "translation" for this "culture_id"

code:

  <?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>

I tried the following: Code:

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

but it does not work ...

Thanks for any help!

+3
source share
1 answer

Since there was no answer, I asked him in some other forums. Here are two possible solutions:

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

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

I prefer this:

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

Source: https://habr.com/ru/post/1708402/


All Articles