数据未存储在Postgres数据库中

时间:2019-01-23 10:06:01

标签: java sql postgresql hibernate

我正在尝试使用postgres将数据保存在hibernate数据库中,但是没有存储任何数据。

这段代码之前工作正常,但是进行一些更改后,没有数据存储在数据库中。即使恢复了更改,此问题仍然无法解决。

Table Structure

CREATE TABLE "public"."dcf_pmtflow_flags_2" (
            "STR_CREATED_BY" character varying(255) COLLATE pg_catalog."default", 
            "DT_CREATED" TIMESTAMP (6) without time zone, 
            "STR_PROPOSAL_NO" character varying(255) COLLATE pg_catalog."default", 
            "STR_SCREEN_REF_NO" character varying(255) COLLATE pg_catalog."default", 
            "STR_LOB_TYPE" character varying(255) COLLATE pg_catalog."default", 
            "STR_PROPOSAL_FLAG" character varying(1) COLLATE pg_catalog."default", 
            "STR_RECEIPT_ENTRY_FLAG" character varying(1) COLLATE pg_catalog."default", 
            "STR_SUBRECEIPT_FLAG" character varying(1) COLLATE pg_catalog."default", 
            "STR_PROPOSAL_TAGGING_FLAG" character varying(1) COLLATE pg_catalog."default", 
            "STR_PDF_GEN_FLAG" character varying(1) COLLATE pg_catalog."default", 
            "STR_FINAL_STATUS" character varying(1) COLLATE pg_catalog."default", 
            "STR_PAYMENT_NO" character varying(255) COLLATE pg_catalog."default", 
            "STR_PRODUCER_CODE" character varying(255) COLLATE pg_catalog."default", 
            "STR_RECEIPT_NO" character varying(255) COLLATE pg_catalog."default", 
            "STR_APPLICATION_NO" character varying(255) COLLATE pg_catalog."default", 
            "STR_SUBRECEIPT_NO" character varying(255) COLLATE pg_catalog."default", 
            "STR_POLICY_NO" character varying(255) COLLATE pg_catalog."default", 
            "STR_ERROR_MSG_RECEIPT_BFL" character varying(2000) COLLATE pg_catalog."default", 
            "STR_ERROR_MSG_SUBRECEIPT" character varying(2000) COLLATE pg_catalog."default", 
            "STR_ERROR_MSG_PROP_TAG" character varying(2000) COLLATE pg_catalog."default", 
            "STR_ERROR_MSG_PDF_GEN" character varying(2000) COLLATE pg_catalog."default", 
            "STR_PROPOSAL_REQ" character varying(2000) COLLATE pg_catalog."default", 
            "STR_PDF_GEN_REQ" character varying(2000) COLLATE pg_catalog."default", 
            "STR_COUNT" character varying(255) COLLATE pg_catalog."default",
            "STR_ADDITIONAL_DTLS_1" character varying(255) COLLATE pg_catalog."default", 
            "STR_ADDITIONAL_DTLS_2" character varying(255) COLLATE pg_catalog."default", 
            "STR_ADDITIONAL_DTLS_3" character varying(255) COLLATE pg_catalog."default", 
            "STR_ADDITIONAL_DTLS_4" character varying(255) COLLATE pg_catalog."default", 
            "STR_ADDITIONAL_DTLS_5" character varying(255) COLLATE pg_catalog."default", 
            "STR_ERROR_MSG" character varying(255) COLLATE pg_catalog."default"
);
  

Java Code: -

public void updatePmtFlowFlag(PmtFlowFlags pmtFlowFlags){

                      Session session = null;
                      Transaction transaction = null;
                        try {
                            if(pmtFlowFlags != null && pmtFlowFlags.getStrproposalno() != null && pmtFlowFlags.getStrproposalno() != ""){
                            session = HibernateUtil.getSessionFactory().getCurrentSession();
                            transaction = session.getTransaction();
                            if(!transaction.isActive()){
                                session.beginTransaction();
                            }
                             PmtFlowFlags pmtOld =(PmtFlowFlags) session.get(PmtFlowFlags.class, pmtFlowFlags.getStrproposalno());
                             if(pmtOld != null){

                                 if(pmtFlowFlags.getStrcreatedby() != null){
                                    pmtOld.setStrcreatedby(pmtFlowFlags.getStrcreatedby());
                                 }
                                if(pmtFlowFlags.getDtcreated() != null){
                                    pmtOld.setDtcreated(pmtFlowFlags.getDtcreated());
                                }
                                if(pmtFlowFlags.getStrproposaltaggingflag() != null){
                                    pmtOld.setStrproposaltaggingflag(pmtFlowFlags.getStrproposaltaggingflag());
                                }

                                if(pmtFlowFlags.getStrreceiptentryflag() != null){
                                    pmtOld.setStrreceiptentryflag(pmtFlowFlags.getStrreceiptentryflag());
                                }
                                if(pmtFlowFlags.getStrlobtype() != null){
                                    pmtOld.setStrlobtype(pmtFlowFlags.getStrlobtype());
                                }

                                if(pmtFlowFlags.getStrpdfgenflag() != null){
                                    pmtOld.setStrpdfgenflag(pmtFlowFlags.getStrpdfgenflag());
                                }
                                if(pmtFlowFlags.getStrpdfgenreq() != null){
                                    pmtOld.setStrpdfgenreq(pmtFlowFlags.getStrpdfgenreq());
                                }
                                if(pmtFlowFlags.getStrproposalflag() != null){
                                    pmtOld.setStrproposalflag(pmtFlowFlags.getStrproposalflag());
                                }
                                if(pmtFlowFlags.getStrproposalreq() != null){
                                    pmtOld.setStrproposalreq(pmtFlowFlags.getStrproposalreq());
                                }
                                if(pmtFlowFlags.getStrfinalstatus() != null){
                                    pmtOld.setStrfinalstatus(pmtFlowFlags.getStrfinalstatus());
                                }
                                if(pmtFlowFlags.getStrpaymnetno() != null){
                                    pmtOld.setStrpaymnetno(pmtFlowFlags.getStrpaymnetno());
                                }
                                if(pmtFlowFlags.getStrscreenrefno() != null){
                                    pmtOld.setStrscreenrefno(pmtFlowFlags.getStrscreenrefno());
                                }
                                if(pmtFlowFlags.getStrpolicyno() != null){
                                    pmtOld.setStrpolicyno(pmtFlowFlags.getStrpolicyno());
                                }
                                if(pmtFlowFlags.getStrreceiptno() != null){
                                    pmtOld.setStrreceiptno(pmtFlowFlags.getStrreceiptno());
                                }
                                if(pmtFlowFlags.getStrcount() != null){
                                    pmtOld.setStrcount(pmtFlowFlags.getStrcount());
                                }
                                if(pmtFlowFlags.getStrerrormsginpdfgen() != null){
                                    pmtOld.setStrerrormsginpdfgen(pmtFlowFlags.getStrerrormsginpdfgen());
                                }
                                if(pmtFlowFlags.getStrerrormsginproptag() != null){
                                    pmtOld.setStrerrormsginproptag(pmtFlowFlags.getStrerrormsginproptag());
                                }
                                if(pmtFlowFlags.getStrerrormsginreceiptBfl() != null){
                                    pmtOld.setStrerrormsginreceiptBfl(pmtFlowFlags.getStrerrormsginreceiptBfl());
                                }
                                if(pmtFlowFlags.getStrapplicationno() != null){
                                    pmtOld.setStrapplicationno(pmtFlowFlags.getStrapplicationno());
                                }

                                if(pmtFlowFlags.getStrlobtype() != null){
                                    pmtOld.setStrlobtype(pmtFlowFlags.getStrlobtype());
                                }
                                if(pmtFlowFlags.getStrsubreceiptno() != null){
                                    pmtOld.setStrsubreceiptno(pmtFlowFlags.getStrsubreceiptno());
                                }
                                if(pmtFlowFlags.getStrsubreceiptflag() != null){
                                    pmtOld.setStrsubreceiptflag(pmtFlowFlags.getStrsubreceiptflag());
                                }
                                if(pmtFlowFlags.getStradditionaldtls1() != null){
                                    pmtOld.setStradditionaldtls1(pmtFlowFlags.getStradditionaldtls1());
                                }
                                if(pmtFlowFlags.getStradditionaldtls2() != null){
                                    pmtOld.setStradditionaldtls2(pmtFlowFlags.getStradditionaldtls2());
                                }
                                if(pmtFlowFlags.getStradditionaldtls3() != null){
                                    pmtOld.setStradditionaldtls3(pmtFlowFlags.getStradditionaldtls3());
                                }
                                if(pmtFlowFlags.getStradditionaldtls4() != null){
                                    pmtOld.setStradditionaldtls4(pmtFlowFlags.getStradditionaldtls4());
                                }
                                if(pmtFlowFlags.getStradditionaldtls5() != null){
                                    pmtOld.setStradditionaldtls5(pmtFlowFlags.getStradditionaldtls5());
                                }
                                if(pmtFlowFlags.getStrerrormsgsubreceipt() != null){
                                    pmtOld.setStrerrormsgsubreceipt(pmtFlowFlags.getStrerrormsgsubreceipt());
                                }
                                if(pmtFlowFlags.getStrproducercode() != null){
                                    pmtOld.setStrproducercode(pmtFlowFlags.getStrproducercode());
                                }
                                if(pmtFlowFlags.getStrapplicationno() != null){
                                    pmtOld.setStrapplicationno(pmtFlowFlags.getStrapplicationno());
                                }

                             }else{
                                session.save(pmtFlowFlags);
                             }

                            transaction.commit();
                            logger.info(className, "DBService", "Schduler Details Stored Successfully: ", "\n");
                          }
                        } catch (Exception e) {
                            logger.fatal("In DBService :: updatePmtFlowFlag error ::"+e.getMessage());
                            e.printStackTrace();
                            transaction.rollback();
                        }finally{
                             if (session != null && session.isOpen()) {
                                 session.close();
                             }
                         }

                    }

hibernate.cfg.xml

`              org.postgresql.Driver

    <!-- Customer Portal SIT DB -->
<property name="hibernate.connection.url">jdbc:postgresql://192.168.38.109/postgres</property> 
        <property name="hibernate.connection.username">postgres</property> <property 
        name="hibernate.connection.password">postgres</property>  



    <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
    <property name="hibernate.hbm2ddl.auto">update</property>

    <property name="hibernate.current_session_context_class">thread</property>
    <property name="hibernate.show_sql">true</property>
    <property name="connection.autocommit">false</property>

    <!-- enable second level cache and query cache -->
    <property name="hibernate.cache.use_second_level_cache">false</property>
    <property name="hibernate.cache.use_query_cache">false</property>


    <property name="hibernate.c3p0.min_size">10</property>
    <property name="hibernate.c3p0.max_size">20</property>
    <property name="hibernate.c3p0.timeout">180</property>
    <property name="hibernate.c3p0.max_statements">50</property>
    <property name="hibernate.c3p0.idle_test_period">3000</property>

    <mapping class="com.majesco.dcf.common.entity.IntermediaryEntity"></mapping>
    <mapping class="com.majesco.dcf.common.entity.InterfaceParam"></mapping>
    <mapping class="com.majesco.dcf.common.entity.PAPremium"></mapping>
    <mapping class="com.majesco.dcf.common.entity.ParameterList"></mapping>
    <mapping class="com.majesco.dcf.common.entity.ParameterDetailList"></mapping>
    <mapping class="com.majesco.dcf.common.entity.UserParameterList"></mapping>
    <mapping class="com.majesco.dcf.common.entity.ExternalMapList"></mapping>
    <mapping class="com.majesco.dcf.common.entity.MessageIncomingEntity"></mapping>
    <mapping class="com.majesco.dcf.common.entity.MessageOutgoingEntity"></mapping>
    <mapping class="com.majesco.dcf.common.entity.RTOLocation"></mapping>
    <mapping class="com.majesco.dcf.common.entity.Motor"></mapping>
    <mapping class="com.majesco.dcf.common.entity.Manufact"></mapping>
    <mapping class="com.majesco.dcf.common.entity.QuotationPA"></mapping>
    <mapping class="com.majesco.dcf.pg.entity.PGMaster"></mapping>
    <mapping class="com.majesco.dcf.pg.entity.PGTransaction"></mapping>
    <mapping class="com.majesco.dcf.common.entity.VehicleAddOn" />
    <mapping class="com.majesco.dcf.common.entity.VehicleIdv" />
    <!-- communication related classes -->
    <mapping class="com.majesco.dcf.common.entity.OTPDetails" />
    <mapping class="com.majesco.dcf.common.entity.EmailSmsContent" />
    <mapping class="com.majesco.dcf.common.entity.EmailAttatchments" />
    <mapping class="com.majesco.dcf.common.entity.UserTransaction" />

    <!-- communication related classes -->
    <!--Start: Code revamping for single hibernate** config file for application -->
    <mapping class="com.majesco.dcf.common.entity.TravelCountryEntity"></mapping>
    <mapping class="com.majesco.dcf.common.entity.Product"></mapping>

    <!--End: Code revamping for single hibernate** config file for application -->
    <!--Start: Code for Travel Details -->
   <mapping class="com.majesco.dcf.common.entity.TravelTransactionDtls"></mapping>
    <mapping class="com.majesco.dcf.common.entity.TravelAddressDtls"></mapping>
    <mapping class="com.majesco.dcf.common.entity.TravelInsuredDetails"></mapping>
    <mapping class="com.majesco.dcf.common.entity.RenewalTransactionData"></mapping>
    <mapping class="com.majesco.dcf.common.entity.PinCode"></mapping>
    <mapping class="com.majesco.dcf.common.entity.City"></mapping>
    <mapping class="com.majesco.dcf.common.entity.State"></mapping>
    <mapping class="com.majesco.dcf.common.entity.Country"></mapping>
    <mapping class="com.majesco.dcf.common.entity.ProposalTransDtls"></mapping>
    <mapping class="com.majesco.dcf.common.entity.AccountServiceErrLog"></mapping>
     <mapping class="com.majesco.dcf.common.entity.PolicyTransactionDetails"></mapping>
     <mapping class="com.majesco.dcf.common.entity.CustomerAAdharDetails"></mapping>
     <mapping class="com.majesco.dcf.common.entity.PmtFlowFlags"></mapping>


    <!--End: Code for Travel Details -->

</session-factory>

我只是想存储这些数据,因为它之前已经工作了

0 个答案:

没有答案