title: How to get last record from Mysql using Hibernate in NetBeans?
body: <p>I find the same question <a href="https://stackoverflow.com/questions/13069689/how-to-get-last-record-from-mysql-using-hibernate">How to get last record from Mysql using Hibernate?</a>     but i dont solved my problem. I want  to get last record from Mysql using Hibernate, this is my code</p>
  
  <p>public class CabinetController implements Controller {</p>
  
  <pre><code>@Override
  public ModelAndView handleRequest(HttpServletRequest hsr,
                                    HttpServletResponse hsr1) throws Exception {
      ModelAndView mv = new ModelAndView("kabinet");
      String out = "Výpis uživatelů: ";
      try {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
       List result = session.createQuery("from Kabinet ORDER BY id  desc LIMIT 1").list();
          mv.addObject("kor", result);
          session.getTransaction().commit();
      } catch (Exception e) {
          e.printStackTrace();
      }
      mv.addObject("message", out);
      return mv;
  }
  </code></pre>
  
  <p>resault is full table whith all records, but I want just 1 last record?</p>
  
  <p>Please help me, it is very important for me!!!</p>