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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:40:46+00:00 2026-05-12T05:40:46+00:00

I have a class say: ClassA which has a collection of ClassB @OneToMany(cascade =

  • 0

I have a class say: “ClassA” which has a collection of “ClassB”

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "COLUMN_NAME")    
private List<ClassB> lotsOfClasses;

“ClassB” has a mapped class “ClassC” using plain old mapping annotations:

public class ClassB {
...
  @ManyToOne
  @JoinColumn(name="AD_POINT_ID")
  private ClassC classC;
...
}

How do I add an @OrderBy annotation to ClassA’s collection to ClassB, so that the collection is ordered by the “name” property of ClassC

Like so:

@OrderBy(clause="classC.name asc")

All I get are Oracle exceptions saying that classC is unknown.

Any help here would be awesome, as its really bugging me at the moment.

P.S. I should also mention that using the OrderBy annotation on the collection like this:
@OrderBy(clause=”classC asc”)
(i.e. without the .name on classC) I get a valid SQL statement, which uses the ID column (the primary key) of classC to order by.

Cheers,
Mark

  • 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-12T05:40:46+00:00Added an answer on May 12, 2026 at 5:40 am

    It’s unfortunately impossible to do what you want. I’ve answered a similar question here.

    @OrderBy only supports direct properties of the collection elements.

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

Sidebar

Related Questions

Let's say we have a class foo which has a private instance variable bar
Let's say I have a Size class which has height and width properties (in
Say I have a class Customer which has a property FirstName . Then I
Let's say I have an class called Star which has an attribute color .
Lets say I have classA which contains classB and both are [Serializable]. I assumed,
Let's say I have a class Collection which holds a list of Items. public
Let's say I have a class, which has a NameValueCollection property. public class TestClass
Say I have a class which represents a person, a variable within that class
I have FrameChangeAnimation class which takes multiple spritesheets and duration. So lets say I
Possible Duplicate: Overload ++ operator Say i have a class in which i overloads

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.