HQL: how to sort a list of objects by the property of the displayed composite element

I have an object with a component map:

<class name="Article" table="articles">
 ...
  <map name="i18nData" table="articles_i18n">
      <key column="id" not-null="true"/>
      <map-key column="language" type="string"/>

      <composite-element class="Article$ArticleI18nData">
        <property name="displayName" type="string"/>
      </composite-element>

    </map>      

</class>

What would the HQL query look like to retrieve all the "article" objects ordered by the "displayName" property of the associated component displayed using the key, for example. 'EN'?

Thank you, Chris

+3
source share
1 answer

Add the arrange attribute to the map element:

<map name="i18nData" table="articles_i18n" order-by="name asc">
  ..
</map>

The attribute value is the database column names.

See:

  • Hibernation documentation - 6.2. Collection Mappings (docs.jboss.org/hibernate/stable/core/reference/en/html/collections-mapping.html)
  • - 6.3.1. (docs.jboss.org/hibernate/stable/core/reference/en/html/collections-advancedmappings.html)

, .

+1

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


All Articles