List<Lahetys> last = session.createQuery("from lahetys order by lahetysNro DESC LIMIT 1").list();
并在日志中我得到:
INFO: Hibernate: select from order by lahetysNro DESC LIMIT 1
WARN: SQL Error: 1064, SQLState: 42000
ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from order by lahetysNro DESC LIMIT 1' at line 1
什么happend“从LAHETYS”? 什么是处理与HQL和/或与SQL的最佳做法?
另一个问题:
Lahetys last = (Lahetys)session.createSQLQuery("select * from lahetys order by lahetysNro DESC LIMIT 1").uniqueResult();
session.getTransaction().commit();
我得到一个例外:
Ljava.lang.Object; cannot be cast to Lahetys
所以我不能投的目的是我Lahetys对象,怪异?
谢谢! 萨米