[Ljava.lang.Object; cannot be cast to mediatek.Pro

使用Hibernate 进行查询错误:

[Ljava.lang.Object; cannot be cast to mediatek.Pro

In the following code I am trying to get a List of Products which contains all the products in the database:

 
 


 org.hibernate.Transaction tx = session.beginTransaction(); products = session.createSQLQuery("SELECT * FROM Products").list(); if(products.size() > 0) { return products; } return null; 


解决方法一:


List<Products> list = session.createCriteria(Products.class).list();


解决方法二:

(List<Products>)session.createSQLQuery("SELECT * FROM Products").addEntity(Products.class).list();


你可能感兴趣的:([Ljava.lang.Object; cannot be cast to mediatek.Pro)