title: HQL query to get all name from a table
body: <p>I have a <strong>StudentInfo</strong> table, I need to fetch all the <strong>names</strong> under <strong>name</strong> column in the table.</p>
  
  <p>can any one help me to correct me in the below function</p>
  
  <pre><code> @Override
   public List&lt;StudentRecord&gt; getAllStudentNames(){
  
          Session session = HibernateUtil.getSessionFactory().openSession();
  
       try {
  
          List&lt;StudentRecord&gt; smrList = new ArrayList&lt;StudentRecord&gt;();
  
              String SQL_QUERY = "select smr.studentName from StudentRecord as smr";
          Query query = session.createQuery(SQL_QUERY)  
  
           smrList  = query.list();
  
  
  
          } catch (Exception e) {
              e.printStackTrace();
  
          } finally {
              session.flush();
              session.close();
              HibernateUtil.getSessionFactory().close();
          }
  
  
          return smrList  
      }
  </code></pre>