最近做个项目遇到个问题,求高手们指点下,感谢!
Service实现类如下代码片段:
@Override
public List<Department> findChildren(Long parentId) {
return sessionFactory.getCurrentSession()
.createSQLQuery(“FROM Department d WHERE d.parent.id=?”)
.setParameter(0, parentId).list();
}
@Override
public List<Department> findTopList() {
return sessionFactory.getCurrentSession()
.createSQLQuery(“FROM Department d WHERE d.parent IS NULL”)
.list();
}
异常如下:
org.hibernate.exception.GenericJDBCException: could not execute query
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
org.hibernate.loader.Loader.doList(Loader.java:2536)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
org.hibernate.loader.Loader.list(Loader.java:2271)
org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544569. Dynamic SQL Error SQL error code = -104 Token unknown – line 1, column 1 FROM
说是执行HQL语句“FROM Department d WHERE d.parent IS NULL”出错