在以下代码中,我试图获取包含数据库中所有产品的产品列表:
public List<Products> getAllProducts() throws Exception{
try{
List<Products> products ;
org.hibernate.Transaction tx = session.beginTransaction();
products = session.createSQLQuery("SELECT * FROM Products").list();
if(products.size() > 0)
{
return products;
}
return null;
}
catch(Exception e)
{
throw e;
}
}
但是抛出了这个异常:
[Ljava.lang.Object; cannot be cast to mediatek.Products