I am trying to fetch the last data in a table using hibernate as shown in the following snippets
query.setMaxResults(1);
List<Long[]> rows = query.list();
System.out.println("current row>>>>>> " +rows.toString());
for (Long[] row: rows) {
System.out.println(" ------------------- ");
long val = (Long) row[6];
System.out.println("current file: " + val);
}
}catch(Exception ex){
ex.printStackTrace();
}
this is my query
Query query = session.createQuery("select f.currentfile.id from File f order by f.id DESC");
I am having the error at this line of the code
java.lang.ClassCastException: java.lang.Long cannot be cast to [Ljava.lang.Long;
for (Long[] row: rows) {
Please what could be wrong?
Long