Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8753105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:21:48+00:00 2026-06-13T13:21:48+00:00

For example, there is a many-to-many association between A and B. And A.bs is

  • 0

For example, there is a many-to-many association between A and B. And

 A.bs is sorted List<B> that sorted by an index-column in the middle-table: idx

So we haven’t mapping idx column as Class field.

Now we want to query the list of B individually and the main condition is A’s id. But when query B directly, it comes out with an unsorted List (don’t order by the idx field).

I know we can retrieve A at first then collect the B into a List. However, considering the framework, we can do like that, it have to return a List without manual coding (don’t want to describe too much about the framework. in one word, this limitation is caused by the pagination tool encapsulate by our self, I don’t want to modify that.).

Is there any methods to solve this problem via HQL/Criteria. Criteria are preferable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:21:49+00:00Added an answer on June 13, 2026 at 1:21 pm

    Okay. This problem has been solved. Using the index() function in hql will get the right result. such as:

    select b from A a left join a.bs b where a.id = ? order by index(b)

    The limitation of index() is that the children must be navigated by parent in hql or it would throw out an exception. means that hql like “select b from B b order by index(b)” is illegal.
    Additionally, don’t use “fetch” in this association navigation(it’s not something concerned in this question).

    hope it’s useful to someone who is puzzled on this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So my DB has a one-to-many association between a customer and orders. Mapping the
I know there are many database design tool, database modeling tool. Example, ER-win ,
WPF is great because there are many ways to achieve your goals. For example,
First of all, there are many cases where Sleep() is misused , for example
I will preface this question with the disclaimer that I know there are many
I have a table called SecurityContacts and another table called Contacts. The association between
We have a model association that looks something like this: class Example < ActiveRecord::Base
I found many examples of generic repository using LINQ to SQL. However there is
Lets say for example there are 5 records shown on screen. I want the
On the Groovy example page there is an example of how to use Groovy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.