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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:17:37+00:00 2026-06-07T16:17:37+00:00

I need to get a resultset via executing a native query in Hibernate. Though

  • 0

I need to get a resultset via executing a native query in Hibernate. Though I am using EntityManager, the query and resultSet may not be entities.

A need to get ResultSet that is of List. Since the select output may vary (read dynamic) i cannot use SqlResultSetMapping.

When i tried the below code i got a result. Since what i am requesting is a single valued result. (Hibernate JPA)

Query query = manager.createNativeQuery("select name from fresher_test where id=1");
List<Object> amount = query.getResultList();

if(amount == null)
 {
    System.out.println("Hey its a null");
    return;
 }
 for(Object e : arr)
 {
   System.out.println(e.toString());
 }

The output was : Alice

When I tried to get more than one select out from the same code with Query as select name,designation from fresher_test where id=1

The output was : [Ljava.lang.Object;@8b1a4f

An object. How do I get the fields from this object?. I tried to typecast object e (List l = (List) e;) to a List but i throws java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List.

This there a way that I could get the values in a List or Array ??

Note : I cannot use a result class/entity since the results could be dynamic.

  • 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-07T16:17:39+00:00Added an answer on June 7, 2026 at 4:17 pm

    When fetching multiple columns, the result is a List<Object[]>. Each Object[] contains one column of the row. So in your case, each Object[] would contain 2 elements, the first one being the name, and the second one being the designation.

    Note that getResultList() will never return null. You shouldn’t check that.

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

Sidebar

Related Questions

Need to get an div with overflow:hidden; not to wrap its children. I need
I've got a CFC performing a query via AJAX to get a list of
I've got two tables that need to be joined via LINQ, but they live
I have a query result set that contains data that I need to filter,
We have been using a web application framework to build apps that need to
I need to get google search results to show in my android app. How
How can I get Google search results from inside a program? I need to
I need to issue multiple $.get requests, process their responses, and record the results
I need get the id of an images which is place inside a datatemplate..
Just need get some vals located in application.ini(main ini) in the Controller plugin I

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.