I having a error with my hibernate project. It gives me a NullPointerException when counts the size of my list(null) cause it breaks when doing the Query and doesnt set the 2 parameters that i pass, when i doint just with one parameter works perfectly.
Here is my code:
AlertsHelper
public List getAlertsList(int level, String Process)
{
List<Dtalerts> list = null;
try
{
if(!this.session.isOpen()){
this.iniciarConexion();
}
Query q = session.createQuery("from Dtalerts as dtalerts where dtalerts.level = :level AND dtalerts.Process = :Process");
//q.setParameter("Fh_alert", Fh_alert);
q.setParameter("level", level);
q.setParameter("Process", Process);
list = (List<Dtalerts>) q.list();
} catch (Exception ex)
{
System.out.println("Excepcion " + ex);
ex.printStackTrace();
}
return list;
}
Jsp
<%
if(request.getParameter("level")!=null){
int level = Integer.parseInt(request.getParameter("level"));
String Process = request.getParameter("Process");
AlertsHelper helper = new AlertsHelper();
List alertList = helper.getAlertsList(level, Process);
out.print("<table border='1'>");
out.print("<tr><th>Level</th><th>Process</th></tr>");
for(int i = 0; i <alertList.size(); i++){
Dtalerts alerts = (Dtalerts) alertList.get(i);
Id = alerts.getId();
level = alerts.getLevel();
Process = alerts.getProcess();
String Description = alerts.getDescription();
out.print("<td><a href='javascript:mostrarDatos(" + level + ",\"" + Process + ")'>Seleccionar</a></td>");
out.print("<tr>");
out.print("<td>" + level + "</td>");
out.print("<td>" + Process + "</td>");
out.print("<td>" + Description + "</td>");
out.print("<td>" + Id + "</td>");
out.print("</tr>");
}
out.print("</table>");
}else{
out.print("introduce un id");
}%>
</form>