Alright guys, I'm just trying to get a list of objects from my table 'ItemList'. I feel like I'm just messing up the query that I'm using. This is the code I'm running:
public List<GetListsDTO> getAllLists() {
Query query = currentSession.createQuery("SELECT L.name, L.listType, L.position FROM ItemList L ORDER BY L.position ASC");
try{
System.out.println(query.list());
return (List<GetListsDTO>) query.list();
}
catch(Exception e){
e.printStackTrace();
return null;
}
}
And this is the result on Postman:
[
[
"list1",
"Clothing",
1
],
[
"list2",
"Clothing",
2
]
]
As you can see it retrieves the right information, but I can't figure out how to cast this into an actual object instead of having it as arrays of strings.
Help would be appreciated :)
EDIT: This is the result I'm looking for:
[
{
"name": "list1",
"listType": "Clothing",
"position": 1
},
{
"name": "list2",
"listType": "Clothing",
"position": 2
}
]