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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:03:22+00:00 2026-05-21T17:03:22+00:00

I have a user entity that has many cars. I cant fetch the user

  • 0

I have a user entity that has many cars.
I cant fetch the user by car list with “IN” statement.

List<Car> cars = getCarsList();
String hql = "From User WHERE user.cars in(:cars)";
Query query = session.createQuery(hql)
query.setParameterList("cars",cars);
//query.setParameterList("cars",cars.toArray());//not working also
//query.setParameter("cars","1,4,8,30");//not working also
query.setMaxResults(1);

In this way, the parameter is cars being ignored.
I have also tries to send vars.toArray();
And I also tried to send String 1,4,8,300 (Ids if cars).

  • 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-21T17:03:23+00:00Added an answer on May 21, 2026 at 5:03 pm

    The user alias is not defined. Try with

    String hql = "from User user inner join user.cars car where car.id in (:carIds)";
    Query query = session.createQuery(hql)
    query.setParameterList("cars", carIds);
    

    where carIds is a collection (and not a string as in your third try) containing the IDs of the cars.

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

Sidebar

Related Questions

I have a User entity that has a Current Location field (city and country).
Lets say I have an entity called User which has many Posts. My service
I have two Entity types: Role and User that have many to many relation.
I have a table that has two different many-to-many relations to two different tables.
I have a JPA domain entity that I'm updating from user input. Depending on
Suppose I have a blog post entity. It has many attributes It has comments
I have three entities: User, Office and PhoneNumber. The user has many phone numbers,
I have an entity relationship setup in my mvc2 application such that each user
I have three entities: Session, User and Test. A session has 0-many users and
I have a core data model defined as follows: A User has many events.

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.