我正在使用Hibernate从数据库读取数据
我使用以下命名查询:
<query name="getTable">
select tbl from ? as tbl order by col
</query>
在DAO中
public List<Object> selectTables(String className){
Query query = session.getNamedQuery("getTable");
query.setParameter(0, className);
return (List<Object>)query.list();
}
当我运行代码时,会出现以下异常。
14:13:57,463 ERROR SessionFactoryImpl:405 - Error in named query: getTable
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ? near line 2, column 25 [
select tbl from ? as tbl order by col
]