将不同的数据保存到数据库中

时间:2016-05-12 05:25:55

标签: java database hibernate maven oracle-sqldeveloper

我对数据库中发生的事情感到困惑。我的代码很好,但是当我将数据保存到数据库中时,例如ABC123,然后当我查看我的数据库时,保存的数据是例如ABC124。

我正在使用Hibernate,Oracle SQL Developer,Java,JSP和MAVEN。

@RequestMapping(value = "/saveNewPairMember.html", method = RequestMethod.POST)
public String saveNewPairData(HttpSession session, HttpServletRequest request, Model model,
        SYSReservation reserve, EMember member,
        memberRelations relation, EmergencyRelative emergency,
        PresentAddress present, EmployerAddress employer, PermanentAddress permanent, AccountResponsible responsible)
        throws ParseException {

    String location = (String) session.getAttribute("location");
    String user = UserUtil.getCurrentUser().getUsername();
    String pinNumber = emember.generateNextPin();
    String memberFlag = request.getParameter("memberFlag");
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    String dateOfBirth = sdf.format(member.getDate_of_birth());
    String pin = "";
    String allAddOnsCodes = request.getParameter("addOnsCodes");
    String addOnsHeader = request.getParameter("addOnsVal");
    List<EMember> searchmember = emember.searchLocalmember(member.getLast_name(), member.getFirst_name(),
            member.getMiddle_name(), member.getSuffix_code(), member.getDate_of_birth(), member.getGender());

    List<SysAdmin> pat = emember.checkmember(member.getFirst_name(), member.getMiddle_name(), member.getLast_name(), member.getSuffix_code(), dateOfBirth, member.getGender(), location);



    if ("1".equals(memberFlag)) {
        String requestNumber = reservation.generateNextVisitNo();
        String partnerRequestNumber = reservation.generateNextVisitNo();
        session.setAttribute("requestNumber", requestNumber);
        session.setAttribute("partnerRequestNumber", partnerRequestNumber);
        log.debug("Request Number(1): " + requestNumber);
        log.debug("Request Number(2): " + partnerRequestNumber);
        reserve.setPartnerRequestNo(partnerRequestNumber);
        reserve.setRequest_no(requestNumber);
        reqNoContainer = requestNumber;
        partReqNoContainer = partnerRequestNumber;
        String sysSelected = (String) session.getAttribute("sysSelected1");
        String ehPinStat = "";

        if (pat.size() >= 1) {
            pin = pat.get(0).getPinNum();
        }
        if (StringUtils.isNotBlank(sysSelected)) {
            ehPinStat = emember.getEhealthPinByHealthCarePin(sysSelected);
        }
        if (StringUtils.isNotBlank(ehPinStat)) {
            if (ehPinStat.equalsIgnoreCase("new")) {
                if (searchmember.isEmpty()) {
                    savemembers(reserve, pinNumber, request, member, relation, emergency, present, employer, session, user, true, false, pin, permanent, responsible, allAddOnsCodes, addOnsHeader, false);
                } else {
                    savemembers(reserve, searchmember.get(0).getpinNumber(), request, member, relation, emergency, present, employer, session, user, false, true, pin, permanent, responsible, allAddOnsCodes, addOnsHeader, false);
                }
            } else {
                savemembers(reserve, ehPinStat, request, member, relation, emergency, present, employer, session, user, false, true, pin, permanent, responsible, allAddOnsCodes, addOnsHeader, true);
            }
        } else {
            if (searchmember.isEmpty()) {
                savemembers(reserve, pinNumber, request, member, relation, emergency, present, employer, session, user, true, false, pin, permanent, responsible, allAddOnsCodes, addOnsHeader, true);
            } else {
                savemembers(reserve, searchmember.get(0).getpinNumber(), request, member, relation, emergency, present, employer, session, user, false, true, pin, permanent, responsible, allAddOnsCodes, addOnsHeader, true);
            }
        }
        session.setAttribute("sysSelected1", "");

        String gender = "";
        if (member.getGender().equalsIgnoreCase("F")) {
            gender = "FEMALE";
        } else {
            gender = "MALE";
        }
        if (reserve.getPreparationSent().equalsIgnoreCase("Y")) {
            paymentAdminService.preparationEmail(reserve, request, member.getEmail_add(), session, gender);
        }
        session.setAttribute("param1", "");
        session.setAttribute("member1", "ok");
    } else if ("2".equals(memberFlag)) {
        reserve.setRequest_no((String) session.getAttribute("partnerRequestNumber"));
        reserve.setPartnerRequestNo((String) session.getAttribute("requestNumber"));

        String sysSelected = (String) session.getAttribute("sysSelected2");
        String ehPinStat = "";

        if (pat.size() >= 1) {
            pin = pat.get(0).getPinNum();
        }
        if (StringUtils.isNotBlank(sysSelected)) {
            ehPinStat = emember.getEhealthPinByHealthCarePin(sysSelected);
        }
        if (StringUtils.isNotBlank(ehPinStat)) {
            if (ehPinStat.equalsIgnoreCase("new")) {
                if (searchmember.isEmpty()) {
                    savemembers(reserve, pinNumber, request, member, relation, emergency, present, employer, session, user, true, false, pin, permanent, responsible, allAddOnsCodes, addOnsHeader, false);
                } else {
                    savemembers(reserve, searchmember.get(0).getpinNumber(), request, member, relation, emergency, present, employer, session, user, false, true, pin, permanent, responsible, allAddOnsCodes, addOnsHeader, false);
                }
            } else {
                savemembers(reserve, ehPinStat, request, member, relation, emergency, present, employer, session, user, false, true, pin, permanent, responsible, allAddOnsCodes, addOnsHeader, true);
            }
        } else {
            if (searchmember.isEmpty()) {
                savemembers(reserve, pinNumber, request, member, relation, emergency, present, employer, session, user, true, false, pin, permanent, responsible, allAddOnsCodes, addOnsHeader, true);
            } else {
                savemembers(reserve, searchmember.get(0).getpinNumber(), request, member, relation, emergency, present, employer, session, user, false, true, pin, permanent, responsible, allAddOnsCodes, addOnsHeader, true);
            }
        }
        session.setAttribute("sysSelected2", "");

        session.removeAttribute("requestNumber");
        session.removeAttribute("partnerRequestNumber");
        String gender = "";
        if (member.getGender().equalsIgnoreCase("F")) {
            gender = "FEMALE";
        } else {
            gender = "MALE";
        }
        if (reserve.getPreparationSent().equalsIgnoreCase("Y")) {
            paymentAdminService.preparationEmail(reserve, request, member.getEmail_add(), session, gender);
        }
        session.setAttribute("param2", "");
        session.setAttribute("member2", "ok");
    }
    model.addAttribute("success", "success");
    return "redirect:/member/memberContainer.html";

}

提前致谢!

0 个答案:

没有答案