Select all from a table hibernate

后端 未结 4 571
余生分开走
余生分开走 2021-02-09 02:46

So I have this following code:

Query query = session.createQuery(\"from Weather\");
        List list = query.list();
        WeatherModel w          


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-09 03:14

    Query query = session.createQuery("from Weather"); //You will get Weayher object
    List list = query.list(); //You are accessing  as list
    

    They both are different entities

    Query query = session.createQuery("from Weather"); 
    
     List list = query.list(); 
    
    Weather w = (Weather) list.get(0);
    

提交回复
热议问题