I am trying get a list with Hibernate. I get a JSONArray with the IN values.
JSONArray rolesEnSession
is, for example, ["ROLE1", "ROLE2"]
public List<MenuLeft> getMenu(JSONArray rolesEnSession){
String listaRoles = "";
for (int i = 0; i < rolesEnSession.length(); i++) {
try {
listaRoles = listaRoles + "'"+rolesEnSession.getString(i)+",";
} catch (JSONException ex) {
Logger.getLogger(LinkDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
}
}
return getCurrentSession()
.createQuery("from MenuLeft "
+ "WHERE menuRol in (:rolesEnSession)")
.setParameter("rolesEnSession", listaRoles)
.list();
}
But I get a blank value. The column menuRol in database has values ROLE1
and ROLE2