• ofbiz 代码日记


     写代码一定要尽善尽美。。

    //修改方法

    //条件查询 用于修改

    List<GenericValue> stoList = delegator.findByAnd("YcrossStorage",UtilMisc.toMap("boxNumber","AMFU8660370"), null, false);
    if(null != stoList && stoList.size() == 1) {
     //获取第一条
     GenericValue storageGV = stoList.get(0);

     storageGV.set("virtualRepair", "1");  //设置字段值

     delegator.store(storageGV); //修改数据

    }

    //sql  语句查询

    String sql = "select * from YREBX_YANXIANG_INFO yx,ycross_storage ys "
         + "where yx.box_no = ys.box_number and yx.yes_status = '0' and ys.yes_storage='1'";
    GenericHelperInfo helperInfo = delegator.getGroupHelperInfo("org.ofbiz");
    SQLProcessor processor = new SQLProcessor(helperInfo);
    ResultSet resultSet = processor.executeQuery(sql); //结果集
    List<String> boxNo = resultSetToList(resultSet);

    //resultSetToList:解析list

    public static List resultSetToList(ResultSet rs) throws java.sql.SQLException {
    if (rs == null)
    return Collections.EMPTY_LIST;
    ResultSetMetaData md = rs.getMetaData(); // 得到结果集(rs)的结构信息,比如字段数、字段名等
    int columnCount = md.getColumnCount(); // 返回此 ResultSet 对象中的列数
    List list = new ArrayList();
    Map rowData = new HashMap();
    while (rs.next()) {
    rowData = new HashMap(columnCount);
    for (int i = 1; i <= columnCount; i++) {
    rowData.put(md.getColumnName(i), rs.getObject(i));
    }
    list.add(rowData);
    System.out.println("list:" + list.toString());
    }
    rs.close();
    return list;
    }

  • 相关阅读:
    LeetCode: Search in Rotated Sorted Array
    LeetCode: Search in Rotated Sorted Array II
    LeetCode: Search Insert Position
    LeetCode: Same Tree
    LeetCode: Search a 2D Matrix
    Oracle工具下载地址
    华为创始人任正非简介
    个人开公司的流程,以后用得着!
    如何更改收藏夹的位置,收藏夹的位置
    帮助大家了解到Google关键字排名、价格
  • 原文地址:https://www.cnblogs.com/w1217/p/6171220.html
Copyright © 2020-2023  润新知