select top 5 {theme.*} from Theme {theme} where state=1 and type=1 order by newid() 改成select top 5 (theme.*) from Theme theme where theme.state=1 and theme.type=1 order by theme.newid()之后用hql语句查询
解决方案 »
- 使用IBatis时,出现错误:SimpleDataSource: Error while loading properties. Cause:java.lang.ClassNotFoundException: "com/mysql/jdbc/Driver
- 求助 LINUX中 用URL表示本地文件 怎么表示呢??谢谢了!
- m个考生的n道题目的作答信息怎么实时保存?
- 一个pager-taglib的问题,急。
- 服务器频繁重启,会有什么不良后果?
- <bean:write>问题--24h结帖
- hibernate 连接DB2数据库。可以插入数据,但不能select
- type="password"中的密码是怎么得到的?
- 菜鸟求助,有关Socket
- 如何从数据库中查找指定字符串最长匹配的记录?
- 心情好 散分
- 求一mysql正则表达式
Query sqlquery=sess.createSQLQuery(sql,"theme",Theme.class);
这样不行?提示什么
public Theme(参数1,参数2,参数3,......){
this.参数1 = 参数1;
this.参数2 = 参数2;
......
}
查询语句这样写:
select top 5 new 你的包名.Theme(参数1,参数2,参数3,......) from Theme t where t.state=1 and t.type=1 order by newid()
SQLQuery query = session.createSQLQuery(sql).addEntity("theme",Theme.class)
把setEntity改成addEntity