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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:09:46+00:00 2026-06-01T12:09:46+00:00

I have Employee table and an Entity class for it, My task is such

  • 0

I have Employee table and an Entity class for it,
My task is such that i need the data of employee table within result set(of type scrollable) two times,
in such case what would be better of the following for using the data second time ->

1: create instance of entity class and store it in List while iterating through result set for first time.
OR
2: after first iteration call the first() method of result set to go back to first row and use data for second time.

Which option will consume less time and resources.
If You have better suggestions, please provide.
Thanks.

  • 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-01T12:09:47+00:00Added an answer on June 1, 2026 at 12:09 pm

    Unless this is about very large resultsets, you’re probably much better off consuming the whole JDBC ResultSet into memory and operating on a java.util.List rather than on a java.sql.ResultSet for these reasons:

    1. The List is more user-friendly for developers
    2. The database resource can be released immediately (which is less error-prone)
    3. You will probably not run out of memory in Java on 1000 rows.
    4. You can make many many mistakes when operating on a scrollable ResultSet, as various JDBC drivers implement this functionality just subtly differently

    You can use tools for consuming JDBC result sets. For instance Apache DbUtils:

    QueryRunner run = new QueryRunner(dataSource);
    ResultSetHandler<List<Person>> h
      = new BeanListHandler<Person>(Person.class);
    List<Person> persons = run.query("SELECT * FROM Person", h);
    

    jOOQ (3.0 syntax):

    List<Person> list =
    DSL.using(connection, sqldialect)
       .fetch("SELECT * FROM Person");
       .into(Person.class);
    

    Spring JdbcTemplate:

    JdbcTemplate template = // ...
    List result = template.query("SELECT * FROM Person", rowMapper);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following 2 entities: @Entity(name = Employee) @Table(name = EMPLOYEE) public class
Suppose I have employee and department table, employee has foreign key departmentID that is
I have main table called 'Employee' and another slave table called 'EmployeeTypes' that has
i have a self join employees entity class with id,name and ref columns that
I have an Entity Framework model with table Employees. Each employee has a SupervisorId,
Technology: Hibernate 3.0 Suppose i have Entity class Company @Entity @Table(name=tbl_companies) public class Company
I have these two entities. One for Employees: [Table(Name = Employees)] public class Employee
I have a table: Employee (employeeID) EmployeeRank (rankID, employeeID) Now I have another table
I have two table Employee and Salary table, salary consists Salary of employee in
I have this function: show_employee_table() -> do(qlc:q([B || B <- mnesia:table(employee)])). What it does

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.