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 6938341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:28:52+00:00 2026-05-27T12:28:52+00:00

I have two domain models: class Resource{ String name static mapping = { sort

  • 0

I have two domain models:

class Resource{
   String name

   static mapping = {
                 sort name:"asc"
          }
}

class ResourceGroup{
   String groupName

   static hasMany = [resources: Resource]
}

controller:

def resGroups = ResourceGroup.findAll()
render (
        view: "index",
        model: [resourcegroups: resGroups]
)

so and now in my gsp:

<g:each in="${resourcegroups}" var="item" status="i">
   ...
   <g:each in="${item.resources}" var="res" status="y">
       <!-- THESE ITEM.RESOURCES ARE UNSORTED! -->
   </g:each>
   ...
</g:each>

my Question is how can I sort this “item.resources”? this is a persistent set of hibernate! I thought this could be handled with the mapping sort name: ‘asc’, but it doesn’t work 🙁

  • 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-05-27T12:28:52+00:00Added an answer on May 27, 2026 at 12:28 pm

    You cannot have a default sort on a one-to-many or many-to-many relationship. See documentation here, paying particular attention to the note at the bottom that says:

    These mappings will not work for default unidirectional one-to-many or many-to-many relationships because they involve a join table. See this issue for more details. Consider using a SortedSet or queries with sort parameters to fetch the data you need.

    The default sort you have specified actually does sort a list of Resource objects (i.e. if you got the list like this Resource.getAll() the list would be sort in the order you specified).

    To do what you want consider creating a tab lib as Don suggests here.

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

Sidebar

Related Questions

I have two RoR3 application: http://users.domain.local http://profiles.domain.local I created the 'users/models/profile.rb': class Profile <
I have a list like this Dim emailList as new List(Of String) emailList.Add(one@domain.com) emailList.Add(two@domain.com)
I have two domains declared in my app. class Posts { String title String
I have the following: class AccountAdmin(models.Model): account = models.ForeignKey(Account) is_master = models.BooleanField() name =
I have two entities in my domain model: public class Configuration : DomainEntity {
I have two tables: books (id, name, desc, instance_id) instances (id, domain) A user
I have two tables that are considered a single entity in my domain model.
If I have two domain names: altcognito.com and say I've got the other following
i have two .net web application and they ara running on different domain same
I'm not very good in SQL and HQL... I have two domains: class Hotel

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.