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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T06:28:01+00:00 2026-05-19T06:28:01+00:00

In HQL, I am trying to use date as a criteria get some data

  • 0

In HQL, I am trying to use date as a criteria get some data but i am getting an error:

Code:

Date DatePlaced=new Date();
        auction.setDatePlaced(DatePlaced);
        auction.setUser((Users) getThreadLocalRequest().getSession(true).getAttribute("User"));
        UpdateDatabase(auction);
        Session session = gileadHibernateUtil.getSessionFactory().openSession();
        Long UserId=(Long) getThreadLocalRequest().getSession(true).getAttribute("UserId");
        String HQL="From Auction auction where User.UserId="+UserId +" and DatePlaced='"+DatePlaced+"'";
        Auction A1=(Auction) session.createQuery(HQL).list().get(0);


Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.RangeCheck(ArrayList.java:547)
    at java.util.ArrayList.get(ArrayList.java:322)
    at com.BiddingSystem.server.ServiceImpl.UpdateAuction(ServiceImpl.java:543)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at net.sf.gilead.gwt.PersistentRemoteService.processCall(PersistentRemoteService.java:174)

What is happening here is mainly due to the date but because no data has been found because the date does not match but the data being used to search is the same date i have set above so 1 row should have been returned

  • 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-19T06:28:03+00:00Added an answer on May 19, 2026 at 6:28 am

    try using named parameters instead of trying to build a query from a string

    Auction A1=(Auction) session
               .createQuery("From Auction auction where User.UserId=:userId and DatePlaced=:placed")
               .setLong("userId",userId)
               .setDate("placed",placed)
               .list().get(0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to code the following HQL query using the Criteria API: var userList
I am trying to use an HQL to perform a simple update in hibernate,
I was trying to fire hql for some reporting purpose in my JPA based
Im a newbie to hibernate and I'm facing an error while trying to use
I'm trying to write a HQL/Criteria/Native SQL query that will return all Employees that
I'm trying to group table values by date, and this HQL query works fine:
I'm having some trouble getting the hang of HQL. I have an application where
I'm trying to get a specific set of data while joining 4 different entities
I am new to Nhibernate, I'm trying to use nhibernate in a project and
I'm trying to get distinct results using the Criteria API in NHibernate. I know

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.