title: How to return int from query?
body: <p>I have this method in my dao implementation, and im trying to return int from the query and put it in the roomNumber int variable, but im not sure if it`s the right syntax... and probably there are other errors. In debug mode i see that the int roomNumber field doesnt get any value, its value is 0 when i step over it.</p>
  
  <pre><code>@Override
      public int getRoomNumber(int bookingId) {
          Session session = sessionFactory.getCurrentSession();
  
          Query query = session.createQuery("select room.roomId from Booking where bookingId=:bookingId");
  
          query.setParameter("bookingId", bookingId);
  
          int roomNumber = query.getFirstResult();
  
          return roomNumber;
      }
  </code></pre>
  
  <p>Booking table in db:</p>
  
  <p><a href="https://i.stack.imgur.com/HhEbd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HhEbd.jpg" alt="enter image description here"></a></p>
  
  <p>for the query i have tried also this: </p>
  
  <pre><code>select room_room_id from Booking where bookingId=:bookingId
  </code></pre>