I am newbie with Hibernate and trying to create an API which will return current position. So in DaoImpl I write a query
public List<Location> getCurrentLocation() {
return sessionFactory.getCurrentSession().createQuery("select l.employee.id, max(l.locationTime) as currentTime, l.longtitude , l.latitude,l.date from Location l group by l.employee.id").list();
}
In controller
@RequestMapping(value = "currentLocation", method = RequestMethod.GET)
public ResponseEntity<List<Location>> getCurrentLocation() {
List<Location> location;
try {
location = locationService.getCurrentLocation();
} catch (Exception e) {
System.out.println(e.getMessage());
return new ResponseEntity<List<Location>>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<List<Location>>(location, HttpStatus.OK);
}
and when I call that API I receive this response
[[11,"07:30:00",106.634756,10.826307,"2017-11-23"],[15,"07:00:00",106.632142,10.826456,"2017-11-24"]]
I just want to ask why I can't get the attribute name. I still don't get it.
Is there any one can explain this, and How can I get the attribute name
for example ['employeename':11,'time':"07:30:00",'longtitude':106.634756,'latitude':10.826307,'workday':"2017-11-23"]
Please help me