提取后如何更新记录

时间:2016-01-29 19:10:01

标签: java hibernate

private List<String> getSCFData(int trdCustomerKy, Date lastRunDate, Date currentDate) throws TradeException {
    List<String> reportData = null;
    String paymentDate = EMPTY_STRING;
    String partyId = EMPTY_STRING;

    YOWDAO hdDAO = new YOWDAO(mConnection);
    List<YOWSCFExtractData> reportItems = hdDAO.getSCFData(trdCustomerKy, lastRunDate, currentDate);
    if (null != reportItems && reportItems.size() > 0) {
        reportData = new ArrayList<String>();
        mTracer.log("Total records retrieved: " + reportItems.size());
        for (YOWSCFExtractData data : reportItems) {
            String Source = (null != data.getSource()) ? data.getSource() : BLANK_STRING;

            String paymentCurrencyCd = (null != data.getPaymentCurrencyCd()) ? data.getPaymentCurrencyCd()
                    : BLANK_STRING;

            String sellerName = (null != data.getSellerName()) ? data.getSellerName() : BLANK_STRING;

            String paymentAmount = (null != data.getPaymentAmount()) ? data.getPaymentAmount() : BLANK_STRING;

            if (null != data.getPaymentDate()) {
                paymentDate = DateUtil.formatDate(data.getPaymentDate());
            }
            if (null != data.getapplCifId()) {
                partyId = hdDAO.getPartyId(mConfiguration.getCustomerKy(), data.getapplCifId());
            }

            String dataRow = StringUtils.join(new String[] { Source, data.getBankRef(), partyId, sellerName,
                    data.getPartyId(), paymentAmount, paymentDate, paymentCurrencyCd}, COMMA);
            reportData.add(dataRow);
        }
    }
    return reportData;
}

我从oracle数据库中提取数据。我想在获取字符串后更新列的记录。例如,当我提取data.getBanref()时,我想在数据库中设置一些字符串。我该怎么办?我正在使用hibernate ........

2 个答案:

答案 0 :(得分:0)

您可以做的是将对象数据设置为您想要的任何值,然后将其保存在休眠中。如果您想要更新,请使用session.saveOrUpdate(),或者如果您想保存新记录,请使用session.save()。希望有所帮助!

答案 1 :(得分:0)

您可以编写一个hibernate查询 更新table_Name column_Name并将其设置为您想要的任何内容,并在您的程序中调用此查询。我认为这样会更容易