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

  • Home
  • SEARCH
  • 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 773557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:59:03+00:00 2026-05-14T18:59:03+00:00

I need to make my web-app work with really huge datasets. At the moment

  • 0

I need to make my web-app work with really huge datasets. At the moment I get either OutOfMemoryException or output which is being generated 1-2 minutes.

Let’s put it simple and suppose that we have 2 tables in DB: Worker and WorkLog with about 1000 rows in the first one and 10 000 000 rows in the second one. Latter table has several fields including ‘workerId’ and ‘hoursWorked’ fields among others. What we need is:

  1. count total hours worked by each user;

  2. list of work periods for each user.

The most straightforward approach (IMO) for each task in plain SQL is:

1)

select Worker.name, sum(hoursWorked) from Worker, WorkLog 
   where Worker.id = WorkLog.workerId 
   group by Worker.name;

//results of this query should be transformed to Multimap<Worker, Long>

2)

select Worker.name, WorkLog.start, WorkLog.hoursWorked from Worker, WorkLog
   where Worker.id = WorkLog.workerId;

//results of this query should be transformed to Multimap<Worker, Period>
//if it was JDBC then it would be vitally 
//to set resultSet.setFetchSize (someSmallNumber), ~100

So, I have two questions:

  1. how to implement each of my approaches with JPA (or at least with Hibernate);
  2. how would you handle this problem (with JPA or Hibernate of course)?
  • 1 1 Answer
  • 1 View
  • 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-14T18:59:04+00:00Added an answer on May 14, 2026 at 6:59 pm

    suppose that we have 2 tables in DB: Worker and WorkLog with about 1000 rows in the first one and 10 000 000 rows in the second one

    For high volumes like this, my recommendation would be to use The StatelessSession interface from Hibernate:

    Alternatively, Hibernate provides a
    command-oriented API that can be used
    for streaming data to and from the
    database in the form of detached
    objects. A StatelessSession has no
    persistence context associated with it
    and does not provide many of the
    higher-level life cycle semantics. In
    particular, a stateless session does
    not implement a first-level cache nor
    interact with any second-level or
    query cache. It does not implement
    transactional write-behind or
    automatic dirty checking. Operations
    performed using a stateless session
    never cascade to associated instances.
    Collections are ignored by a stateless
    session. Operations performed via a
    stateless session bypass Hibernate’s
    event model and interceptors. Due to
    the lack of a first-level cache,
    Stateless sessions are vulnerable to
    data aliasing effects. A stateless
    session is a lower-level abstraction
    that is much closer to the underlying
    JDBC.

    StatelessSession session = sessionFactory.openStatelessSession();
    Transaction tx = session.beginTransaction();
    
    ScrollableResults customers = session.getNamedQuery("GetCustomers")
        .scroll(ScrollMode.FORWARD_ONLY);
    while ( customers.next() ) {
        Customer customer = (Customer) customers.get(0);
        customer.updateStuff(...);
        session.update(customer);
    }
    
    tx.commit();
    session.close();
    

    In this code example, the Customer
    instances returned by the query are
    immediately detached. They are never
    associated with any persistence
    context.

    The insert(), update() and
    delete() operations defined by the
    StatelessSession interface are
    considered to be direct database
    row-level operations. They result in
    the immediate execution of a SQL
    INSERT, UPDATE or DELETE
    respectively. They have different
    semantics to the save(),
    saveOrUpdate()
    and delete()
    operations defined by the Session
    interface.

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

Sidebar

Related Questions

I'm planning on creating a small web app using PHP. The last time I
I need some type of JS MVC, DataBinding solution. Similar to implementing a GMAIL
EDIT I need to change www.myhost.com:8080/myproject-war to www.myhost.com . Here is what I've been
Some Background I have an iPhone app with three UIWebViews, each used to show
What I am trying to do – Make a JNI call to a shared
url = new java.net.URL(s) doesn't work for me. I have a string C:\apache-tomcat-6.0.29\webapps\XEPServlet\files\m1.fo and
Ok, maybe i'm not seeing the whole picture or something, but i kinda need
I have a desktop application that on first execution prompts for the connection details
I built a parsing application that reads xml files and populates an Excel workbook
I'm using Spring 3.0.3 with Spring Security. So, I have fairly lenient restrictions on

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.