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

  • Home
  • SEARCH
  • 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 8262693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:50:25+00:00 2026-06-08T03:50:25+00:00

I have a SortedSet within an entity. But when I try to fetch it

  • 0

I have a SortedSet within an entity. But when I try to fetch it doesn’t sort. I tried to use hibernate or jpa, both not working. Any reason? (My set entity has implemented comparable too)

    private SortedSet<News> news = new TreeSet<News>();

    public void setNews(SortedSet<News> news) {
    this.news = news;
}

    @OneToMany(fetch = FetchType.EAGER,  cascade = {CascadeType.PERSIST, CascadeType.MERGE })
    @JoinTable(name = "NEWSGROUP_NEWS", joinColumns = @JoinColumn(name = "NEWSGROUP_ID"), inverseJoinColumns = @JoinColumn(name = "NEWS_ID"))
    @OrderBy("title")
    @Sort(type=SortType.COMPARATOR, comparator=NewsComparator.class)
    public SortedSet<News> getNews() {
        return this.news;
    }

public static class NewsComparator implements Comparator<News>
    {

        @Override
        public int compare(News news1, News news2) {
            return news1.getTitle().compareTo(news2.getTitle());

        }

    }

My Dao

NewsGroup newsGroup = (NewsGroup)this.hibernateSessionFactory.getCurrentSession().get(NewsGroup.class, id);

I have also printed the sql (with show_sql on) but it doesn’t show order by at all.
Please advise.
Thanks!

  • 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-08T03:50:27+00:00Added an answer on June 8, 2026 at 3:50 am

    JMelnik is right, by removing the @Sort, it worked

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

Sidebar

Related Questions

I have a SortedSet holding my ordered data. I use the .first() method to
The ItemsSource (SsString) is a SortedSet string I want to use a TextBox (not
I'd like to have a SortedSet of Collections (Sets themselves, in this case, but
I'm trying to use .NET 4's SortedSet<T> collection. It seems to have everything I
Have 2 tables in Access 2007, both lists of certain tasks to be accomplished.
I have a SortedSet defined this way: SortedSet<RatedMessage> messageCollection = new TreeSet<RatedMessage>(new Comp()); and
I have a class : class Category { String name SortedSet items static hasMany
I have a service that produces as result a SortedSet object. I need to
I have this before the process: protected void onPostExecute(SortedSet<RatedMessage> result) { List<Object> list=Arrays.asList(result.toArray()); lancon.putExtra(results,
As far as I know, things such as SortedMap or SortedSet , use compareTo

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.