解决方案 »

  1.   

    没有这一列。仔细检查,看大小写之类的。saleinfo贴上来,对应的映射文件。
      

  2.   

    hibernate找不到此行记录,是不是中间处理过程被你删掉对象了?
      

  3.   


    public void setValidityPeriod(Double validityPeriod) {
    this.validityPeriod = validityPeriod;
    } @Column(name = "DEAL_INFO_ID")
    public String getDealInfoId() {
    return dealInfoId;
    } public void setDealInfoId(String dealInfoId) {
    this.dealInfoId = dealInfoId;
    } @Column(name = "DEAL_INFO_NO")
    public String getDealInfoNo() {
    return dealInfoNo;
    } public void setDealInfoNo(String dealInfoNo) {
    this.dealInfoNo = dealInfoNo;
    }
    @Column(name = "EXPIRATION", length = 7)
    public Date getExpiration() {
    return this.expiration;
    } public void setExpiration(Date expiration) {
    this.expiration = expiration;
    } @Column(name = "NOTE")
    public String getNote() {
    return this.note;
    } public void setNote(String note) {
    this.note = note;
    } @Column(name = "SELL_TYPE")
    public String getSellType() {
    return this.sellType;
    } public void setSellType(String sellType) {
    this.sellType = sellType;
    } @Column(name = "TOP_PRICE", precision = 10)
    public Double getTopPrice() {
    return this.topPrice;
    } public void setTopPrice(Double topPrice) {
    this.topPrice = topPrice;
    } @Column(name = "BASE_PRICE", precision = 10)
    public Double getBasePrice() {
    return this.basePrice;
    } public void setBasePrice(Double basePrice) {
    this.basePrice = basePrice;
    } @Column(name = "BEGIN_TIME", length = 7)
    public Date getBeginTime() {
    return this.beginTime;
    } public void setBeginTime(Date beginTime) {
    this.beginTime = beginTime;
    } @Column(name = "END_TIME", length = 7)
    public Date getEndTime() {
    return this.endTime;
    } public void setEndTime(Date endTime) {
    this.endTime = endTime;
    } @Column(name = "MARGIN", precision = 10)
    public Double getMargin() {
    return this.margin;
    } public void setMargin(Double margin) {
    this.margin = margin;
    } @Column(name = "STATUS")
    public String getStatus() {
    return this.status;
    } public void setStatus(String status) {
    this.status = status;
    } @Column(name = "SELL_USERNAME")
    public String getSellUsername() {
    return this.sellUsername;
    } public void setSellUsername(String sellUsername) {
    this.sellUsername = sellUsername;
    } @Column(name = "SELL_PENAME")
    public String getSellPename() {
    return this.sellPename;
    } public void setSellPename(String sellPename) {
    this.sellPename = sellPename;
    } @Column(name = "CREATOR_ID")
    public String getCreatorId() {
    return this.creatorId;
    } public void setCreatorId(String creatorId) {
    this.creatorId = creatorId;
    } @Column(name = "CREATOR_NAME")
    public String getCreatorName() {
    return this.creatorName;
    } public void setCreatorName(String creatorName) {
    this.creatorName = creatorName;
    } @Column(name = "CREATION_DATE", length = 7)
    public Date getCreationDate() {
    return this.creationDate;
    } public void setCreationDate(Date creationDate) {
    this.creationDate = creationDate;
    } @Column(name = "LASTEDITOR_ID")
    public String getLasteditorId() {
    return this.lasteditorId;
    } public void setLasteditorId(String lasteditorId) {
    this.lasteditorId = lasteditorId;
    } @Column(name = "LASTEDITOR_NAME")
    public String getLasteditorName() {
    return this.lasteditorName;
    } public void setLasteditorName(String lasteditorName) {
    this.lasteditorName = lasteditorName;
    } @Column(name = "LASTEDIT_DATE", length = 7)
    public Date getLasteditDate() {
    return this.lasteditDate;
    } public void setLasteditDate(Date lasteditDate) {
    this.lasteditDate = lasteditDate;
    } @Column(name = "IS_ENABLED")
    public String getIsEnabled() {
    return this.isEnabled;
    } public void setIsEnabled(String isEnabled) {
    this.isEnabled = isEnabled;
    } @Column(name = "FLAG")
    public String getFlag() {
    return this.flag;
    } public void setFlag(String flag) {
    this.flag = flag;
    } @Column(name = "BUSINESS_INFO")
    public String getBusinessInfo() {
    return this.businessInfo;
    } public void setBusinessInfo(String businessInfo) {
    this.businessInfo = businessInfo;
    } @Column(name = "VERSION", precision = 8, scale = 0)
    public Integer getVersion() {
    return this.version;
    } public void setVersion(Integer version) {
    this.version = version;
    } @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "saleInfo")
    public Set<BidRecord> getBidRecords() {
    return this.bidRecords;
    } public void setBidRecords(Set<BidRecord> bidRecords) {
    this.bidRecords = bidRecords;
    } @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "saleInfo")
    public Set<BidMargin> getBidMargins() {
    return this.bidMargins;
    } public void setBidMargins(Set<BidMargin> bidMargins) {
    this.bidMargins = bidMargins;
    } @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "saleInfo")
    public Set<SellMargin> getSellMargins() {
    return this.sellMargins;
    } public void setSellMargins(Set<SellMargin> sellMargins) {
    this.sellMargins = sellMargins;
    } @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "saleInfo")
    public Set<Bill> getBills() {
    return this.bills;
    } public void setBills(Set<Bill> bills) {
    this.bills = bills;
    } @Column(name = "SUB_TRANSFER_ID")
    public String getSubtransferId() {
    return subtransferId;
    } public void setSubtransferId(String subtransferId) {
    this.subtransferId = subtransferId;
    } @Column(name = "LISTING_FEE")
    public Double getListingFee() {
    return listingFee;
    } public void setListingFee(Double listingFee) {
    this.listingFee = listingFee;
    }
    }
      

  4.   

    关联映射的问题。
    有两张表,table1和table2.产生此问题的原因就是table1里做了关联<one-to-one>或者<many-to-one unique="true">(特殊的多对一映射,实际就是一对一)来关联table2.当hibernate查找的时候,table2里的数据没有与table1相匹配的,这样就会报No row with the given identifier exists这个错.(一句话,就是数据的问题!)
             假如说,table1里有自身的主键id1,还有table2的主键id2,这两个字段.
             如果hibenrate设置的单项关联,即使table1中的id2为null值,table2中id2中有值,查询都不会出错.但是如果table1中的id2字段有值,但是这个值在table2中主键值里并没有,就会报上面的错!
             如果hibernate是双向关联,那么table1中的id2为null值,但是table2中如果有值,就会报这个错.这种情况目前的解决办法就是改成单项关联,或者把不对应的数据改对!
      

  5.   

    package com.hwmy.service;import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.HashSet;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;
    import org.springside.modules.orm.PageInfo;import com.hwmy.dao.SaleInfoDao;
    import com.hwmy.dao.WarrantDao;
    import com.hwmy.model.BidMargin;
    import com.hwmy.model.BidRecord;
    import com.hwmy.model.Bill;
    import com.hwmy.model.BuyMargin;
    import com.hwmy.model.DealInfo;
    import com.hwmy.model.DealItem;
    import com.hwmy.model.MandateTransfer;
    import com.hwmy.model.RegisterInfo;
    import com.hwmy.model.SaleInfo;
    import com.hwmy.model.SellMargin;
    import com.hwmy.model.SubTransfer;
    import com.hwmy.model.Warrant;
    import com.hwmy.util.BankUtil;
    import com.hwmy.util.Params;
    import com.jyfw.model.AdminInfo;
    import com.jyfw.system.service.AdminInfoService;
    import com.jyfw.util.CommonUtil;
    import com.jyfw.util.ParamUtil;@Service
    @Transactional
    public class SaleInfoService extends SuperService {
    private Logger log = LoggerFactory.getLogger(SaleInfoService.class);
    private static String businessInfo_addSaleInfo_update = "仓单信息管理-发布销售信息,修改仓单状态信息";
    private static String businessInfo_deleteSaleInfo_update = "仓单信息管理-发布销售信息,修改仓单状态信息";
    private static String businessInfo_delete = "销售信息管理-删除销售信息";
    private static String businessInfo_addBidRecord_update = "销售信息管理-添加竞买记录信息,修改销售信息竞买最高价信息";
    private static String businessInfo_addExpiresBidRecord_update = "销售信息管理-增加甩单出价记录信息,修改销售信息甩单最高价信息";
    private static String businessInfo_updateExpiresBidRecord_update = "销售信息管理-更新甩单出价记录信息,修改销售信息甩单最高价信息";
    private static String businessInfo_add = "订单信息管理-新添订单信息";

    @Autowired
    private SaleInfoDao dao;
    @Autowired
    private WarrantDao warrantDao;
    @Autowired
    private WarrantService warrantService;
    @Autowired
    private BidRecordService bidRecordService;
    @Autowired
    private BidMarginService bidMarginService;
    @Autowired
    private DealItemService dealItemService;
    @Autowired
    private DealInfoService dealInfoService;
    @Autowired
    private BillService billService;
    @Autowired
    private AdminInfoService adminInfoService;
    @Autowired
    private SubTransferService subTransferService;
    @Autowired
    private BuyMarginService buyMarginService;
    @Autowired
    private SellMarginService sellMarginService;

    @Transactional(readOnly = true)
    public SaleInfo get(String id) {
    return dao.get(id);
    } @Transactional
    public void save(SaleInfo entity) {
    dao.save(entity);
    log.info("保存SaleInfo,id为{}", entity.getId());
    } // 删除销售信息
    @Transactional
    public boolean deleteSaleInfo(String saleInfoId, String operationtype, String operatorId, String operatorName) {
    // 通过id获取销售信息对象
    SaleInfo saleInfo = dao.get(saleInfoId);
    // 判断销售信息是否生成订单
    if (saleInfo.getBills() != null && !saleInfo.getBills().isEmpty()) {
    return true;
    }
    // 判断竞买、竞卖、甩单销售信息是否有人竞价
    if (saleInfo.getBidMargins() != null && !saleInfo.getBidMargins().isEmpty()) {
    return true;
    }
    //通过销售信息关联出仓单对象
    Warrant warrant = saleInfo.getWarrant();
    saleInfo.setWarrant(null);
    // bidRecordService.deleteBySaleInfo(saleInfo);
    // saleInfo.setBidRecords(null);
    // bidMarginService.deleteBySaleInfo(saleInfo);
    // saleInfo.setBidMargins(null);
    if(warrant != null){
    warrant.setSaleInfos(null);
    warrant.setTradeStatus(Params.WARRANT_TRADESTATUS_UNUSED);
    warrant.setBusinessInfo(businessInfo_deleteSaleInfo_update);
    String warrantOperationtype = Params.OPERATIONTYPE_UPDATE;
    warrantService.save(warrant, Warrant.class, warrantOperationtype);
    }
    if (saleInfo.getStatus().equals(Params.SALE_INFO_WAITINGMARGIN)) {
    delete(saleInfoId, SaleInfo.class, operationtype, operatorId, operatorName, businessInfo_delete);
    log.info("删除SaleInfo,id为{}", saleInfoId);
    } else {
    saleInfo.setStatus(Params.SALE_INFO_EXPRIED);
    save(saleInfo, SaleInfo.class, Params.OPERATIONTYPE_UPDATE);
    }
    // TODO 大坑
    // // 对应请求代码:DLMDETRN
    // String action = ParamUtil.getParavalueByTypecodeAndKey(Params.BCLink, Params.BCLink_MandateTransferAction);
    // // <!--登录名 varchar(20) -->
    // String username = ParamUtil.getParavalueByTypecodeAndKey(Params.BCLink, Params.BCLink_userName);
    // // <!--客户流水号varchar (20) -->
    // String clientid = CommonUtil.getNo(Params.QZZZ);
    // // <!--主体账号varchar(19) -->
    // String accountno = ParamUtil.getParavalueByTypecodeAndKey(Params.BCLink, Params.BCLink_mainStayAccont);
    // // 从卖家信息中获得保证金账户(在此作为付款账户)
    // RegisterInfo seller = adminInfoService.findByUsername(saleInfo.getSellUsername()).getRegisterInfo();
    // // <!--付款账号varchar(19) -->
    // String payaccno = seller.getGuarantyAccount();
    // // <!--转账类型varchar(2) "BF":转账;"BG":解冻;"BH":解冻支付-->
    // String trantype = "BF";
    // // 获得平台的交易账户,作为收款账户
    // // <!--收款账号varchar(19) -->
    // String recvaccno = ParamUtil.getParavalueByTypecodeAndKey(Params.HWMY_ACCOUNT, Params.HWMY_ACCOUNT_007);
    // // <!--收款账户名称varchar(60) -->
    // String recvaccnm = ParamUtil.getParavalueByTypecodeAndKey(Params.HWMY_ACCOUNT, Params.HWMY_ACCOUNT_008);
    // // <!--交易金额decimal(15,2) -->
    // double tranamt = Double.valueOf(ParamUtil.getParavalueByTypecodeAndKey(Params.BUY_MARGIN_BID, Params.SALE_LISTING_FEE));
    // // <!--冻结编号varchar(22) 转账类型为"解冻"或"解冻支付"时,必输-->
    // String freezeNo = "";
    // // <!--摘要varchar(22) 可空-->
    // String memo= "";
    // String id = CommonUtil.getID();
    // String no = CommonUtil.getNo(Params.QZZZ);
    // // 生成强制转账记录
    // MandateTransfer mandateTransfer = new MandateTransfer(id, no, action, username, 
    // clientid, accountno, payaccno, trantype, recvaccno, recvaccnm, tranamt);
    //
    // saleInfo.setSubtransferId(id);
    // mandateTransfer.setCreatorId(Params.CreatorId_system_job);
    // mandateTransfer.setCreatorName(Params.CreatorName_system_job);
    // mandateTransfer.setCreationDate(new Date());
    // // 保存转账记录
    // save(mandateTransfer, MandateTransfer.class, Params.OPERATIONTYPE_ADD);
    // save(saleInfo, SellMargin.class, Params.OPERATIONTYPE_UPDATE);
    // String getXmlMargin = getXmlMargin(action, username, clientid, accountno, 
    // payaccno, trantype, recvaccno, recvaccnm, tranamt, freezeNo, memo);
    // String submitResult = BankUtil.doBCLink(BankUtil.BCLink_url, getXmlMargin);
    // Map<String, Object> submitResultMap = BankUtil.parseXml(submitResult);
    // // 获取银企直连的响应报文内容
    // String status = submitResultMap.get("status").toString();
    // String statusText = submitResultMap.get("statusText").toString();
    // mandateTransfer.setStatus(status);
    // mandateTransfer.setStatustext(statusText);
    // // 判断报文提交状态
    // if (status.equals(ParamUtil.getParavalueByTypecodeAndKey(Params.BCLink, Params.BCLink_Response_SubmitSuccess))) {
    // // 如果报文提交状态是“已提交银行处理,需稍后使用‘交易状态查询’进行查询”,则置卖家保证金记录的状态为“银行退还处理中”
    // saleInfo.setStatus(Params.SALE_INFO_LISTINGFEESUBMIT);
    // save(saleInfo, SellMargin.class, Params.OPERATIONTYPE_UPDATE);
    // } else {
    // // 如果报文提交状态异常,则置卖家保证金记录的状态为“退还提交失败”
    // saleInfo.setStatus(Params.SALE_INFO_LISTINGFEEFAIL);
    // save(saleInfo, SellMargin.class, Params.OPERATIONTYPE_UPDATE);
    // }
    // save(mandateTransfer, MandateTransfer.class, Params.OPERATIONTYPE_UPDATE);
    return false;
    }

    //判断销售信息是否已经生成订单
    // public boolean isCreateBill(String saleInfoId) {
    //
    // } //查询功能
    @SuppressWarnings("unchecked")
    @Transactional(readOnly = true)
    public List<SaleInfo> query() {
    String hql = "from SaleInfo s where status='"+Params.SALE_INFO_PUBLISHED+"' order by s.creationDate desc" ;
    return dao.executeQuery(hql);
    }
    //竞价查询(发布时间限制)
    @Transactional(readOnly = true)
    public List<SaleInfo> query(Map<String, String>[] map, PageInfo pageInfo) {
    Date now = new Date();
    SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String now1 = sd.format(now);
    //String hql = "from SaleInfo s where 1=1 and to_char( s.beginTime,'yyyy-MM-dd HH:mm:ss') >= '"+ now1 +"' and to_char( s.endTime,'yyyy-MM-dd HH:mm:ss') <= '"+now1+"'";
    String hql = "from SaleInfo s where 1=1 and to_char(s.beginTime, 'yyyy-MM-dd HH24:mi:ss')<= '"+ now1 +"'";
    hql = CommonUtil.handleQueryString(map, hql); 
    hql += " order by s.creationDate desc";
    return dao.executeQuery(hql, pageInfo);
    }
    //定价查询(发布时间限制)
    @Transactional(readOnly = true)
    public List<SaleInfo> queryNormal(Map<String, String>[] map, PageInfo pageInfo) {
    String hql = "from SaleInfo s where 1=1 ";
    hql = CommonUtil.handleQueryString(map, hql); 
    hql += " order by s.creationDate desc";
    return dao.executeQuery(hql, pageInfo);
    }
    //查询功能(当前登录者的信息)
    @Transactional(readOnly = true)
    public List query(Map<String, String>[] map, PageInfo pageInfo, String username) {
    String hql = "from SaleInfo s where 1=1 and sellUsername= '"+ username + "'";
    hql = CommonUtil.handleQueryString(map, hql);
    hql += " order by no desc";
    return dao.executeQuery(hql, pageInfo);
    }
    这是saleinfoService层的一部分