2
我使用Hibernate來讀取數據庫 數據我用下面的命名查詢:傳類名AA參數命名查詢
<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
]