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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:34:11+00:00 2026-06-16T00:34:11+00:00

I have three entities with relation UserDetails hasmany FiledTask and Task hasMany FiledTask .

  • 0

I have three entities with relation UserDetails hasmany FiledTask and Task hasMany FiledTask. All I want is list of FiledTask of particular User

For UserDetails:

@OneToMany(mappedBy="user",cascade=CascadeType.ALL)
Collection<FiledTask> filedTasks = new ArrayList<FiledTask>();

And for Tasks I have

@OneToMany(mappedBy="task")
Collection<FiledTask> filedTasks = new ArrayList<FiledTask>();

And FiledTask looks like

@ManyToOne
@JoinColumn(nullable = false, name = "taskId")
private Tasks task;
@ManyToOne
@JoinColumn(nullable = false, name = "userId")
private UserDetails user;

I have tried

query = session.createQuery("from Tasks as tasks inner join tasks.filedTasks as files with files.user = :user");
query.setParameter("user", user); //user is UserDetails instance

But I am getting error clause can only reference columns in the driving table, means FiledTask can’t userId for comparision?

with clause can only reference columns in the driving table [from com.akhi.app.cdm.Tasks as tasks inner join tasks.filedTasks as files with files.user = :user]
  • 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-16T00:34:12+00:00Added an answer on June 16, 2026 at 12:34 am

    If you want the FiledTasks of a given user, then the easiest thing to do is

    UserDetails user = session.find(UserDetails.class, userId);
    Collection<FiledTask> filesTasks = user.getFiledTasks();
    

    Using HQL, it would be

    select f from FiledTask f where f.user = :user
    

    If what you want is in fact the tasks of a given user, then the query would simply be

    select t from Tasks t
    inner join t.filedTasks filedTask
    where filedTask.user = :user
    

    Note that the entity Tasks shouldbe named Task. An instance represents a single task, and not multiple ones.

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

Sidebar

Related Questions

hi i have two entities User and Authority they have many to many relation:
I have three entities: User, Office and PhoneNumber. The user has many phone numbers,
I have two entities User and Department, There is a bidirectional relation between the
I have three entities: Country, State and City with the following relationships: When creating
I have three entities: EntityA, EntityB and EntityC connected with to-many relationships. See schema
I have three entities. Author Newspaper Dissertation Newspaper and Dissertation both can have one
I have a case where i have three entities with one-to-many and one-to-many relationships:
Have three classes User, Group and Field. Many to many relationship on User /
Have three divs in a container that I want to float over a large
I have this escenario... I have three 4 entities {orderItem, suppliers, supplier, prices}, and

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.