hibernate query全查询问题 查询所有数据返回的是0
publicList<Area>findarea(){System.out.println("zhixing");Sessionsession=sessionFactor...
public List<Area> findarea() {
System.out.println("zhixing");
Session session = sessionFactory.openSession();
Transaction tx=session.beginTransaction();
String hql = "from Area";
Query query = session.createQuery(hql);
System.out.println(query.list().size());
List<Area> arealist=query.list();
System.out.println(arealist.size());
tx.commit();
//Criteria criteria=session.createCriteria(User.class);
for(Area entity:arealist){
System.out.println(entity.toString());
}
if(arealist==null){
System.out.println("rong");
}
return arealist;
} 展开
System.out.println("zhixing");
Session session = sessionFactory.openSession();
Transaction tx=session.beginTransaction();
String hql = "from Area";
Query query = session.createQuery(hql);
System.out.println(query.list().size());
List<Area> arealist=query.list();
System.out.println(arealist.size());
tx.commit();
//Criteria criteria=session.createCriteria(User.class);
for(Area entity:arealist){
System.out.println(entity.toString());
}
if(arealist==null){
System.out.println("rong");
}
return arealist;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询