I have Route Entity class and when I'm going to fetch all the data from that table in HQL query I get an error for a only one column.
Route.class :-
@Entity
public class Route {
@Id
private long routeID;
private String start;
private String end;
private String routeNo;
private double startLat;
private double startLon;
private double endLat;
private double endLon;
}
DataFetch.Class :-
public class DataFetch{
public void FetchRoutes(){
Query q = session.createQuery("select routeID,routeNo,start,end from Route ");
List<Object[]> routes = (List<Object[]>) q.list();
for (Object[] r : routes) {
System.out.println("id: "+r[0]);
System.out.println("No: "+r[1]);
System.out.println("start: "+r[2]);
System.out.println("end: "+r[3]);
}
}
}
In DataFetch.class if i remove "end" column from the query q there are no errors. but if i add end again as shown this question,it will give an error. below I show my error as a screen shot.
What is the problem?
ENDbeing a reserved word? try to quote it, like"end"...