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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:30:14+00:00 2026-06-12T16:30:14+00:00

I have a query which in the worst case will create upwards of 150K

  • 0

I have a query which in the worst case will create upwards of 150K entities. Probably with an upward limit of 300,000k entities. I have tried several ways to return this set of data back to the user… I run the query just using sql Developer and it runs in about .348 seconds. So that is not a bottle neck of any kind.

I create a nested query like so…

List<Object[]> ObjList = (List<Object[]>) emf.createNativeQuery(assembleNestedQuery(query2)).getResultList();

The native query is assembled as such…

String query2 = assembleQuery(organizationIDs, 2);

else if (type == 4){ 
    queryBuilder.append("SELECT t0.RESOURCE_ID, t0.FIRST_NAME,  t0.MIDDLE_NAME, t0.LAST_NAME FROM EPCD13.Provider t0");
    if(typeArgs.length > 0){ 
        queryBuilder.append("  WHERE t0.RESOURCE_ID IN (");             
        for(int i = 0 ; i <= typeArgs.length - 1; i++){
        if(i != typeArgs.length -1)
            queryBuilder.append(typeArgs[i] +", ");
        else
            queryBuilder.append(typeArgs[i] +" ");
        if((i % 1000 == 0) && (i != 0)){
            queryBuilder.append(") OR IN (");
        }
    }
    queryBuilder.append(")");               
            }
    }

private String assembleNestedQuery(String typeArgs2){
        StringBuilder queryBuilder = new StringBuilder();
        queryBuilder.append("SELECT t0.RESOURCE_ID, t0.FIRST_NAME,  t0.MIDDLE_NAME, t0.LAST_NAME FROM EPCD13.Provider t0");
        queryBuilder.append("  WHERE t0.RESOURCE_ID IN (");
        queryBuilder.append(typeArgs2);
        queryBuilder.append(")");
        return queryBuilder.toString();
    }

That above code basically assembles this query…

SELECT t0.RESOURCE_ID, t0.FIRST_NAME,  t0.MIDDLE_NAME, t0.LAST_NAME FROM EPCD13.Provider t0  WHERE t0.RESOURCE_ID IN (SELECT DISTINCT d.RESOURCE_ID FROM EPCD13.RESOURCES d WHERE d.ORGANIZATION_ID in (...))

So the nested query is basically created dynamically…
The query that I run has about 155K records returned. Now I basically run the below code to turn the results into Provider objects…

List<Provider> provList = new ArrayList<Provider>(); 
for(Object[] obj: ObjList)
{
    provList.add(this.GetProviderFromObj(obj));
}

And this is where the exception are occuring. Is this too large a set of data for JPA to handle? I could do this with some simple Java JDBC connections and some basic Java objects pretty simply. But is this set of data to large to work with?

Thanks.

UPDATE: Exception I am getting

java.lang.OutOfMemoryError: caused by: java.lang.OutOfMemoryError
  • 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-12T16:30:15+00:00Added an answer on June 12, 2026 at 4:30 pm

    It sounds like are you trying to use a data set that is too large for your JVM. You could either pull less number of objects into memory, or you could increase your max heap.

    I’d also suggest looking at Large Result Sets.

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

Sidebar

Related Questions

I have this query which on executing in my sql command line client executes
I have a query which returns two rows of data as count. I want
I have this query which is a dependant query and taking much execution time
I have this query which groups the results by ORDER#. SELECT ORDER#, MAX(SHIPDATE -
I have a query which looks like this: SELECT LossCost, CoverageID FROM BGILossCost] WHERE
I have a query which produces a list of orders like this: Invoice Description
I have this query which works correctly in MySQL. More background on it here
I have a query which searches two separate fields in the same table... looking
I have a query which returns a series of cells of data from a
I have a query which part of a SP which is executed fairly regularly,

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.