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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:00:00+00:00 2026-06-14T01:00:00+00:00

it is my second time that i play with jpa, i wrote this pice

  • 0

it is my second time that i play with jpa,

i wrote this pice of code:

   String queryString = "SELECT e.uidprofile, e.profilecode, e.catUso, max(e.zonaClim), e.classePrev, e.beta1, e.beta2, e.beta3, e.beta4"
            + " FROM "
            +  entityClass.getSimpleName()
            + " e "
            + " WHERE e.catUso like :code "
            + " group by e.uidprofile, e.profilecode, e.catUso, e.classePrev, e.beta1, e.beta2, e.beta3, e.beta4"
            + " order by e.uidprofile";

    Query query = entityManager.createQuery(queryString);

    query.setParameter("code", "C" + "%");

    List<SamTbProfileMapping> resultList = query.getResultList();

    ClassLoader c1 = this.getClass().getClassLoader();
    ClassLoader c2 = resultList.getClass().getClassLoader();

    if(resultList.size()>0){
        System.out.println(resultList.get(0).getCatUso());
    }

Debugging it:

  • resultList has all the fields of SamTbProfileMapping with the right values
  • the count of the objects is right
  • after the line List<SamTbProfileMapping> resultList = query.getResultList();
    i get C2 to null and System.out.println(resultList.get(0).getCatUso());
    says that resultList can not be Casted To SamTbProfileMapping
  • 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-14T01:00:01+00:00Added an answer on June 14, 2026 at 1:00 am

    You are retrieving a list of arrays with your query. Not a list of objects.

    "Select a, b, c, d, from something" – returns List<Object[]>

    Then access separate members in the same order as in query.
    For example:

     List<Object[]> myList = query.getResultList();
    
     MyAClass a1 = (MyAClass) myList.get(0)[0];
     MyBClass b1 = (MyBClass) myList.get(0)[1];
    

    To select an object list you can use:

    "select a from MyClass a where ..."

    Then

     List<MyClass> myList = query.getResultList();
     MyClass result1 = myList.get(0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I execute an ajax function that takes 3 seconds + so in this time
How do I disable a textbox the second time? here is my code, In
I need to have the same short wav file (1 second) play each time
I'm writing a cross-platform Qt-based program that from time to time needs to play
I'm using this code to play a WAV file from a resource, and the
Since the second time of bundle install execution, dependencies are loaded from Gemfile.lock as
it is my second time asking a question on stackoverflow. I'm trying to access
For the second time today git commit -m don't quit me now deletes my
my first time is 12:10:20 PM and second time is 7:10:20 Am of the
I'm getting follwing error while I'm trying to filter data for the second time

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.