Hibernate常见问题
1) 当用myeclipse生成对象的xml时,如果用classes12.jar包的话可以生成带注释的XML文件。
2) Query q = session.createQuery("from Chat order by id desc");
q.setFirstResult(0);
q.setMaxResults(10);
报错:com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 '10 chat0_.id as id0_, chat0_.username as username0_, chat0_.message as message0_' at line 1查找好久没有找到原因,后看后台打印语句,发现为:
select top 11 chat0_.id as id0_, chat0_.username as username0_, chat0_.message as message0_,
chat0_.timeastime0_
fromtest.chatchat0_
order by chat0_.id desc因为我的数据库为mysql,而mysql选取部分结果集应为limit 0,10这样,查看Hibernate方言后发现用的是sqlserver方言,故改成mysql后成功!
相关推荐
emmm00 2020-11-17
王艺强 2020-11-17
aydh 2020-11-12
世樹 2020-11-11
zry 2020-11-11
URML 2020-11-11
spurity 2020-11-10
yifangs 2020-10-13
Andrea0 2020-09-18
Ida 2020-09-16
ltd00 2020-09-12
tufeiax 2020-09-03
xjd0 2020-09-10
greatboylc 2020-09-10
adsadadaddadasda 2020-09-08
疯狂老司机 2020-09-08
sunnyxuebuhui 2020-09-07