org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: 29 near line 1, column
来源:互联网 发布:pm2 node schedule 编辑:程序博客网 时间:2024/06/06 05:12
在购物网站项目中首页需要展示前面一部分的品牌,在Dao层的代码如下
/** * 获取指定数量的品牌信息 * @param count 指定数量 * @return 指定数量的品牌信息 */@SuppressWarnings("unchecked")public List<Brand> getBrand(int count) {String hql = "select top "+count+" from Brand";return (List<Brand>)getHibernateTemplate().find(hql);}
运行时报如下错误:
org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: 29 near line 1, column 12 [select top 29 from com.paixie.domain.Brand];
原来:在使用hibernate通过session操作数据库时,session根据的查询语句都是hql。如: session.createQuery("from Brand"); 它的语句中不存在select * ,所有如果将hql语句误写成sql语句,它是不认得*号的,才会报那样“unexpected token: * near line 1, column 8”的错。
- org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: 29 near line 1, column
- org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: 29 near line 1, column
- org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: * near line 1, column
- org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: xx near line 1, colum
- org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: where near line 1, col
- org.springframework.orm.hibernate3.HibernateQueryException: ClassNotFoundException:
- org.springframework.orm.hibernate3.HibernateQueryException 问题
- SSH org.springframework.orm.hibernate3.HibernateQueryException
- org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 16
- org.hibernate.hql.ast.QuerySyntaxException: unexpected token: from near line 1, column 17 [select co
- org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: * near line 1, column 8
- org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: u near line 1, column 55 [fro
- org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: b near line 1, column 49...
- unexpected token: * near line 1, column 8 [select * from tb_cat]
- org.springframework.orm.hibernate3.HibernateQueryException: teacherscore is not mapped
- 十二、org.springframework.orm.hibernate3.HibernateQueryException: Book is not mapped
- org.springframework.orm.hibernate3.HibernateQueryException:表名 is not mapped
- org.springframework.orm.hibernate3.HibernateQueryException: XXX is not mapped
- 派生类构造与析构函数
- 简单程序流程
- 获取系统硬件信息
- Arrest HDU 费用流
- CentOS64bit下安装oracle11.2系统配置
- org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: 29 near line 1, column
- Struts2 的三种接受参数的方式
- poj1466最大独立集
- SYMBIAN OS:描述符
- ubuntu9.10下安装配置NFS服务
- Ubuntu9.10下安装配置tftp服务器
- wireshark中sequence number (BE)(LE)
- Android中关于外部存储的一些重要函数
- HDU 3724 Encoded Barcodes Trie