大家来给看看这个错误怎么解决

来源:百度知道 编辑:UC知道 时间:2024/05/29 04:17:02
错误:org.hibernate.hql.ast.QuerySyntaxException: unexpected token: fromCustomero near line 1, column 10 [select o fromCustomero]

这是代码: @SuppressWarnings("unchecked")
@Transactional(readOnly = true, propagation = Propagation.NOT_SUPPORTED)
public <T> PagedResult<T> getScrollData(Class<T> entityClass,
int startPosition, int maxResult) {
PagedResult<T> result = new PagedResult<T>();
String entityName = this.getEntityName(entityClass);
Query query = em.createQuery("select o from" + entityName+"o");
if (startPosition > 0 && maxResult > 0) {
query.setFirstResult(startPosition);
query.setMaxResults(maxResult);
}
result.setResultList(query.getResultList());

query = em.createQuery("select count(o) from" + entityName + "o");
result.setTotalRecords((Long) query.getSingleResult());
return result;

unexpected token: fromCustomero
你拼写的hql有问题了,缺一个空格,把
"select o from" + entityName+"o"
改成
"select o from " + entityName+" o"

select o fromCustomero
select o from Customero

话说看起来有点乱。。

楼主学的比我深奥,看不懂啊