0

I am trying to insert or update data in database using stored procedure in My batis but query was run succesfully but data is not inserted in DB. can u please help me out.

below is the calling stored procedure in mapper.xml:

<select id="saveExaminations" resultMap="examinationForm">
        {call SaveExaminationForms(12,31,null, 1, 100.00,0,0, 1, 0, 1, 1, 1, 1, 1, 1000001,0,1,123456,0,1,BCA,0000000003,2011,
        fraud,allahabad,null,Hindi,1,2,1,8)}
    </select>

below is the resultmap in mapper.xml

<resultMap id="examinationForm" type="ExaminationForm">
        <result property="id" column="EXAMINATIONFORM_ID"/>
        <result property="studentId" column="EXAMINATIONFORM_STUDENTID"/>
        <result property="examinationId" column="EXAMINATIONFORM_EXAMINATIONID"/>
        <result property="isSubmitted" column="EXAMINATIONFORM_ISSUBMITTED"/>
        <result property="feeAmount" column="EXAMINATIONFORM_FEEAMOUNT"/>
        <result property="paymentTypeId" column="EXAMINATIONFORM_PAYMENTTYPEID"/>
        <result property="bankId" column="EXAMINATIONFORM_BANKID"/>
        <result property="isClass10CertAttached" column="EXAMINATIONFORM_ISCLASS10CERTATTACHED"/>
        <result property="isClass12CertAttached" column="EXAMINATIONFORM_ISCLASS12CERTATTACHED"/>
        <result property="isUGCertAttached" column="EXAMINATIONFORM_ISUGCERTATTACHED"/>
        <result property="isPGCertAttached" column="EXAMINATIONFORM_ISPGCERTATTACHED"/>
        <result property="isReservationCategoryCertAttached" column="EXAMINATIONFORM_ISRESERVATIONCATEGORYCERTATTACHED"/>
        <result property="isDomicileCertAttached" column="EXAMINATIONFORM_ISDOMICILECERTATTACHED"/>
        <result property="isMigrationCertAttached" column="EXAMINATIONFORM_ISMIGRATIONCERTATTACHED"/>
        <result property="MigrationCertificateNo" column="EXAMINATIONFORM_MIGRATIONCERTIFICATENO"/>
        <result property="isBankChallanAttached" column="EXAMINATIONFORM_ISBANKCHALLANATTACHED"/>
        <result property="isEmployerNOCAttached" column="EXAMINATIONFORM_ISEMPLOYERNOCATTACHED"/>
        <result property="EmployerNOCNumber" column="EXAMINATIONFORM_EMPLOYERNOCNUMBER"/>
        <result property="isAnyOtherAttachment" column="EXAMINATIONFORM_ISANYOTHERATTCHMENT"/>
        <result property="wasPunishedForUFM" column="EXAMINATIONFORM_WASPUNISHEDFORUFM"/>
        <result property="uFMExamName" column="EXAMINATIONFORM_UFMEXAMNAME"/>
        <result property="uFMRollNo" column="EXAMINATIONFORM_UFMROLLNO"/>
        <result property="uFMYear" column="EXAMINATIONFORM_UFMYEAR"/>
        <result property="uFMPunishmentDetails" column="EXAMINATIONFORM_UFMPUNISHMENTDETAILS"/>
        <result property="uFMCentreName" column="EXAMINATIONFORM_UFMCENTRENAME"/>
        <result property="otherDegreeParticulars" column="EXAMINATIONFORM_OTHERDEGREEPARTICULARS"/>
        <result property="mediumOfExamination" column="EXAMINATIONFORM_MEDIUMOFEXAMINATION"/>
        <result property="candidateCategory" column="EXAMINATIONFORM_CANDIDATECATEGORY"/>
        <result property="createdDate" column="EXAMINATIONFORM_CREATEDDATE"/>
        <result property="sessionYearId" column="EXAMINATIONFORM_SESSIONYEARID"/>
        <result property="classId" column="EXAMINATIONFORM_CLASSID"/>
        <result property="courseId" column="EXAMINATIONFORM_COURSEID"/>
        <result property="subjectName" column="EXAMINATIONFORM_SUBJECTNAME"/>
    </resultMap>

below code in my dao file

public void saveExaminations() throws PersistenceException{
        SqlSession session = sf.openSession();
        try{
            System.out.println("Before calling save procedure in dao file :");
            System.out.println("output of save : " + session.insert("saveExaminations"));
            System.out.println("after calling save procedure in dao file:");

        }catch(Exception e ){
            System.out.println("error in executing submit data");
        }
        finally{
            session.close();
        }
    }

Anyone have any idea about this one why this data is not inserted in db after calling saveExaminations().

3
  • query was run succesfully but data is not inserted ... Any exceptions raised? Commented Dec 21, 2013 at 8:26
  • Not any single exception raised........ I am trying to see DB log..... Commented Dec 21, 2013 at 9:31
  • 1
    looks like MySQL procedure call, if your tables are transactional committing might help: session.commit() Commented Dec 21, 2013 at 13:47

1 Answer 1

1

SqlSession session = sf.openSession(); does not create auto commit session. To create one use

SqlSession session = sf.openSession(true);

Or use session.commit() in the end.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.