0

Spring APIを使用してデータベースにレコードを挿入しようとしていますSimpleJdbcInsert...しかし、モデルオブジェクトが変数を運ぶときに問題が発生します...変数を としてBoolean設定すると、実際にデータベースに値が挿入されます...私のコードは次のようになります以下...私を助けてください..よろしくお願いします..BooleantrueNULL

    DiscountController.java

            discount = getDiscountData();
            discount = discountService.saveDiscount(discount);

    public Discount getDiscountData() 
        {
            Discount discount = new Discount();
            discount.setDiscountSchemeName("Early Bird Incentive");
            discount.setSchemeType("Volume Discount");
            discount.setDiscountStartDate(DateUtil.stringToDate("01/01/2018"));
            discount.setDiscountEndDate(DateUtil.stringToDate("30/06/2018"));
            discount.setEnabled(true);
            return discount;
        }


    DiscountService.java

    @Override
        public Discount saveDiscount(Discount discount) throws Exception 
        {
            return discountDAO.saveDiscount(discount);
        }


    DiscountDAO.java




    @Override
        public Discount saveDiscount(Discount discount) throws ServiceException {

              String logStr = discount.toString();
              int ID = -1;

                  logger.debug(" Discount Insert: " + logStr);
                  SqlParameterSource discountParams = new BeanPropertySqlParameterSource(discount);
                  ID = new SimpleJdbcInsert(dataSource).withTableName("TBL_DISCOUNT")
                      .usingGeneratedKeyColumns("Id").executeAndReturnKey(discountParams).intValue();

                  if (ID <= 0)
                  {
                      logger.error(" Discount Insert: ID returned " + ID + ": " + logStr);
                      throw new Exception("Internal error while saving Discount information");
                  }
                  else
                  {
                      logger.info(" Discount Insert: ID returned " + ID + ": " + logStr);
                      discount.setID(ID);
                  }
    }// End of function

Discount.java


    public class Discount extends GenericEntity{

        private String discountSchemeName,schemeType;
        private Date discountStartDate,discountEndDate;
        private boolean isEnabled;

        public String getDiscountSchemeName() {
            return discountSchemeName;
        }

        public void setDiscountSchemeName(String discountSchemeName) {
            this.discountSchemeName = discountSchemeName;
        }

        public String getSchemeType() {
            return schemeType;
        }

        public void setSchemeType(String schemeType) {
            this.schemeType = schemeType;
        }

        public Date getDiscountStartDate() {
            return discountStartDate;
        }

        public void setDiscountStartDate(Date discountStartDate) {
            this.discountStartDate = discountStartDate;
        }

        public Date getDiscountEndDate() {
            return discountEndDate;
        }

        public void setDiscountEndDate(Date discountEndDate) {
            this.discountEndDate = discountEndDate;
        }

        public boolean getEnabled() {
            return isEnabled;
        }

        public void setEnabled(boolean isEndabled) {
            this.isEnabled = isEndabled;
        }
    }
4

0 に答える 0