title: Can we get single object from hql query?
body: <p>I am writing a select query in hql , my task is to activate the bus. First I will get a messege from client as <code>busId#busStatus</code>, so first I look for this perticular busId is active or inactive So I have to write select query but in hibernate <code>query.list()</code> returns <code>list</code>. Here I think list is unnecessary , a single object is enough .</p>
  
  <p>Here is my code ,</p>
  
  <pre><code>    String hql="from BusDetailBean where Busid= :busId and bus_status=:busStatus";
          Query query = session.createQuery(hql);
          query.setParameter("busId", busId);
          query.setParameter("busStatus", busStatus);
  
          List&lt;BusDetailBean&gt; busDetails=(List&lt;BusDetailBean&gt;)query.list(); 
         if(busDetails.isEmpty())
          {
               //my other stuff
          }
           else
           {
  
              //bus ativation stuff
           }
  </code></pre>
  
  <p>My question is the select query returns only one object if list is not empty I have to use for loop in else part. So how can I optimise this code. can anyone help me in this.</p>