我需要在DAO方法中使用setter吗?

时间:2017-10-27 09:37:28

标签: java spring hibernate spring-mvc

  

DAO方法    我无法在此处使用setter方法

@SuppressWarnings("unchecked")
    public ArrayList<shopModel> viewShopinfo() {
        ArrayList<shopModel> list = new ArrayList<shopModel>();
        shopModel sh=new shopModel();
        try 
        {           
           session.beginTransaction();          
           String viewQuery="SELECT * FROM shop_information";           
           query = session.createSQLQuery(viewQuery);
           query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);//To execute A Select Query
           query.setParameter("storeName", sh.getStoreName());
           query.setParameter("ownername", sh.getOwnername());
           list = (ArrayList<shopModel>) query.list();
           System.out.println("List values : "+ query.setParameter("ownername", sh.getOwnername()));
        } 
        catch (Exception ex) 
        {
            ex.printStackTrace();
            System.out.println("Class :shopDao Method viewShopinfo Exception :"
                    + ex);
        } 
        finally 
        {
            session.getTransaction().commit();
            session.close();
        }
        return list;
    }

JSP页面

<%                      
                 shopService shp=new shopService();
                ArrayList<shopModel> list=shp.viewShopinfo();
                System.out.println("welcome list : " + list.size());                
                 for (int index=0; index<list.size(); index++)  
                 {
                     System.out.println("welcome index : " + list.size());
                       shopModel shop = list.get(index);                        
                     System.out.println("welcome Store : " + shop.getStoreName()); 
                  %>

错误页面

  

.Class:shopDao Method viewShopinfo Exception   :org.hibernate.QueryParameterException:找不到named   参数[storeName]。

1 个答案:

答案 0 :(得分:1)

weighted_value_counts(df[['Quantity','Item']], normalize=True) 中的参数store name在哪里? 您的查询必须是这样的

query