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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:22:47+00:00 2026-05-28T04:22:47+00:00

I just want to make a simple native query with EclipseLink, but I can’t

  • 0

I just want to make a simple native query with EclipseLink, but I can’t make it work

    @Repository("CarsRepository")
public class JpaCarsRepository {

    @PersistenceContext 
    private EntityManager em;

    public List<Car> getCars(){
     Query q=em.createNativeQuery("SELECT id,name_car FROM CARS",Car.class);
     List<Car> results=q.getResultList();

My ‘Car’ class is defined as an @Entity. (my persistence.xml has just the basic connection settings) I get a ‘Missing descriptor’ error for class ‘Car’.

Why is this happening? I saw a similar question which didn’t help me.

2nd question:

If I don’t specify the 2nd parameter of ‘createNativeQuery’ function (Car.class), it returns a list of Objects, so I can see results.get(0) value is [1 car]. I can iterate over the list of objects. So if

Object o=results.get(0)

I could create the Car objects manually, but I don’t know how to get first value of the object, if I print o[0] to get value 1 of the object (which is [1 car]) I get the following error the type of expression must be array type but resolved to object

How could I access to each value of the object?

  • 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-05-28T04:22:47+00:00Added an answer on May 28, 2026 at 4:22 am

    It does not consider Car as entity, looks like it is not scanned. Does listing your entity inside class-element in persistence.xml help?

    Your second attempt returns list of object arrays. To access values you have to first cast to the one row of result set to Object array:

    Object[] o=results.get(0)
    //types below are just guessed:
    Integer id = o[0];
    String name = o[1];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just want to make simple extension for syntactic sygar : public static bool IsNotEmpty(this
ok pretty simple but i dont know how... i just want to make an
I can't seem to find an answer on this and just want to make
Its probarbly a simple 3-tier problem. I just want to make sure we use
I am new to python, and just want to make a simple change. We
I had make a simple app into a facebook page and I just want
Hi I just want to make sure I have these concepts right. Overloading in
I just want to set a crontab using that I want to make a
i am done with my iphone application.Now i just want to make a binary
I am doing a md5 hash, and just want to make sure the result

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.