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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:37:50+00:00 2026-06-10T01:37:50+00:00

I have the below Hibernate NamedQuery that runs into issues when one of the

  • 0

I have the below Hibernate NamedQuery that runs into issues when one of the “in” expressions has 1000 or more items. When I have 1000 or more items in the ma.deviceId in (:devices), I get java.sql.SQLException: ORA-01795: maximum number of expressions in a list is 1000

The only “in” expression that I need to take care of is the “and ma.deviceId in (:devices)”. Anyone have any ideas on how to rewrite this NamedQuery? I’m using JPA and Hibernate.

@NamedQuery(name = "Messages.findMessages", query = " SELECT ma from Messages ma JOIN FETCH ma.messagePayLoadXml mx LEFT OUTER JOIN FETCH ma.messageProperties  mp " +
                  " WHERE ma.customerId = :customerId and ma.time >= :startTime and ma.time <= :endTime " +
                  " and ma.deviceId in (:devices) and  mx.messageType = 'XML' and mx.alerts in " +
                  " ( select mtfm.messageType from MessageTypeFeatureMap mtfm where mtfm.feature in (:featureType) ) " +
                  " and ma.messageKey = mx.messageKey and ( mp.deleted = 0 or mp.deleted is null ) " +
                  " order by ma.time desc " )
  • 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-10T01:37:52+00:00Added an answer on June 10, 2026 at 1:37 am

    There are 2 ways.
    1) Store your list in intermediary table and do
    ... IN (SELECT ... FROM intermediaryTable)
    2) Break your list into sublists each upto 1000 elements and write your query as
    (... IN (subList1) OR ... IN (subList2) ...)

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

Sidebar

Related Questions

I have a subselect query (like the one below) in my hibernate mapping XML
I have such query (generated by Hibernate - edited for more clarity - below
I have a project with spring and hibernate in GWT, I am using below
I currently have the below tables representing a bus network mapped in hibernate, accessed
I have setup my classes like below. Hibernate ddl generates 2 tables Admin and
I have hibernate query as below: String mySql = SELECT S.col1, S.col2, T.col3, T.col4,
I have an application that is connected to an SQL database using Hibernate. When
I have a spring bean that I have configured in applicationContext like below: <bean
I have one-to-many mapping in hibernate between a Parent and a Child . In
I am using java/hibernate/Oracle. i have a list with more than 3000 entries. if

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.