title: How can i get count(*) from SQL Using getHibernateTemplate()?
body: <p>I want to get the number of DEVICES from a table and show the results on my Html page , i have the following Code and when i run this code i get the Null pointer Exception in my bean :</p>
  
  <p>DashboardDaoImp.java // Dao implementation</p>
  
  <pre><code>public int getNumberOfDevices(){
  
      return DataAccessUtils.intResult(getHibernateTemplate().find("SELECT COUNT(DISTINCT deviceid) from Device"));
  }
  </code></pre>
  
  <p>DashboardDao.java // Dao Interface</p>
  
  <pre><code>public interface DashbordDao {
  
  int getNumberOfDevices();
  </code></pre>
  
  <p>}</p>
  
  <p>DashboardBoImp.java // Bo implementation</p>
  
  <pre><code>DashbordDao dashbordDao;
  
  @Override
  public int getNumberOfDevices() {
  
      return dashbordDao.getNumberOfDevices();
  }
  </code></pre>
  
  <p>DashboardBoImp.java // Bo interface</p>
  
  <pre><code>public interface DashbordBo {
  
  int getNumberOfDevices();   
  }
  </code></pre>
  
  <p>DashboardBean.java // My bean</p>
  
  <pre><code>public int getNumberOfDevices()
      {
      samssnb_device = dashboardBo.getNumberOfDevices();
  
      return samssnb_device;
      }
  </code></pre>
  
  <p>// My Html page</p>
  
  <pre><code>&lt;h3&gt;#{dashbord.getNumberOfDevices()}&lt;sup style="font-size: 20px"&gt;&lt;/sup&gt;&lt;/h3&gt;
                &lt;p&gt;Number of devices &lt;/p&gt;
  </code></pre>
  
  <p>// Stack Trace </p>
  
  <p><a href="http://i.stack.imgur.com/6tbGq.png" rel="nofollow">Stack Trace Image</a></p>