EclipseLink error: Exception Description: Missing descriptor for class
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];
de3
Updated on June 04, 2022Comments
-
de3 almost 2 years
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?
-
de3 over 12 yearsI added previosuly my entity in persistence.xml with no success, but after trying again I found out my error was not specifying @Id, and @Column(name="columname") in my Car model class' properties