码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2015-11-06 16:34:31      阅读:271      评论:0      收藏:0      [点我收藏+]

标签:

使用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

标签:

原文地址:http://my.oschina.net/liting/blog/526957

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!