Suppose I have a table Person and i want to count all those people whose \"birthDate\" is not null and they are a student. Assuming i have two columns :
birthDat
Use it. It's working
public class IncIncidentListGridModel
{
private String historyStatus = null;
public String getHistoryStatus()
{
return historyStatus;
}
public void setHistoryStatus(String historyStatus)
{
this.historyStatus = historyStatus;
}
public void run()
{
IncIncidentListGridModel resultCount =
(IncIncidentListGridModel) ((SQLQuery) hibersession
.createSQLQuery("select count(ch.incident_capa_history_id) as historyStatus from incident_capa_history ch, incident_capa ic where ic.incident_capa_id = ch.FK_incident_capa_id and ic.incident_capa_id='011'"))
.addScalar("historyStatus", Hibernate.STRING)
.setResultTransformer(
Transformers.aliasToBean(IncIncidentListGridModel.class))
.uniqueResult();
System.out.println("count result" + resultCount.getHistoryStatus());
}
}