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
“来自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 对象上,奇怪吗?
谢谢!萨米人