Announcement Announcement Module
Collapse
No announcement yet.
Spring's Declarative Transaction - is not rolling back Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring's Declarative Transaction - is not rolling back

    Hi All ,
    I am facing a problem with Spring's Declarative Transaction Demarcation . My Spring's config file is like this :-

    <bean id="ReminderManager"
    class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager"><ref local="ReminderTransactionManager"/></property>
    <property name="target"><ref local="ReminderManagerTarget"/></property>
    <property name="transactionAttributes">
    <props>
    <prop key="updateSmocksEmailCount">PROPAGATION_REQUIRED,-qc.esd.model.exception.ReminderActionFailedExcepti on</prop>
    </props>
    </property>
    </bean>

    <bean id="ReminderManagerTarget" class="qc.esd.model.service.impl.ReminderManagerIm pl">
    <property name="mailSender">
    <ref bean="MAIL_SENDER"/>
    </property>
    <property name="esdUserDAO">
    <ref bean="ESDUSER_DAO"/>
    </property>
    <property name="esdAdminDAO">
    <ref bean="ESDADMIN_DAO"/>
    </property>
    <property name="from">
    <value>[email protected]</value>
    </property>
    </bean>

    I have configured "updateSmocksEmailCount" method as transactional . The method defination is like this :-

    public void updateSmocksEmailCount(final SmockRequest smockRequest,
    final String status) throws ReminderActionFailedException {
    if (logger.isDebugEnabled()) {
    logger.debug("updateSmocksEmailCount(SmockRequest, String) - start");
    }

    try {
    this.getEsdUserDAO().addModifySmockRequest(smockRe quest);
    } catch (DataIntegrityViolationException dive) {
    logger.error(dive);
    throw new ReminderActionFailedException(dive.getMessage());
    } catch (ConcurrencyFailureException cfe) {
    logger.error(cfe);
    throw new ReminderActionFailedException(cfe.getMessage());
    } catch (DataAccessException dae) {
    logger.error(dae);
    throw new ReminderActionFailedException(dae.getMessage());
    }

    final QbsPhPeople people = smockRequest.getQbsPhPeople();
    final String append = "@" +
    ESDUtil.getValue(ESDConstants.ESD_CONFIG, ESDConstants.DOMAIN_NAME);
    final String to = people.getEmailAddr() + append;

    try {
    this.sendMail(to, cc, subject, content, null, null);
    } catch (MailSendException mse) {
    logger.error(mse);
    throw new ReminderActionFailedException(mse.getMessage());
    } catch (MessagingException mse) {
    logger.error(mse);
    throw new ReminderActionFailedException(mse.getMessage());
    }

    if (logger.isDebugEnabled()) {
    logger.debug("updateSmocksEmailCount(SmockRequest, String) - end");
    }
    }


    I am calling this method from another method of the ReminderManager . It is like this :-

    public void performActivity() throws ScheduledJobProcessingFailedException {
    if (logger.isDebugEnabled()) {
    logger.debug("performActivity() - start");
    }

    try {
    final List receivedSmocks = this.getReceivedSmockList();

    final int size = receivedSmocks.size();

    for (int cnt = 0; cnt < size; cnt++) {
    try {
    final SmockRequest smockRequest = (SmockRequest) receivedSmocks.get(cnt);
    smockRequest.getObjSmockStatus().setStatusId(ESDCo nstants.UNPICKED);
    this.updateSmocksEmailCount(smockRequest,
    ESDConstants.IN_ACTIVE);
    } catch (ReminderActionFailedException rafe) {
    logger.error(rafe);
    }
    } catch (DataAccessException dae) {
    logger.error(dae);
    throw new ScheduledJobProcessingFailedException( dae.getMessage());
    }

    if (logger.isDebugEnabled()) {
    logger.debug("performActivity() - end");
    }
    }


    i.e i am calling transactional method in loop. My main concern is ,it is not rolling back database updates if mail sending fails.

    I AM NOT ABLE TO GET , WHY IT IS NOT ROLLING IT BACK .


    Can anybody suggest me what is going wrong in my code or configuration ?

    Thanks in advance,
    Vaibhav

  • #2
    1. if you are using MySQL make sure you have InnoDB tables (not MyISAM or smth else).
    2. turn on logging to see if spring actually catches your exception and starts the rollback.
    3. your code could use some refactoring - there is no point in using checked exceptions; there are very good threads about unchecked exceptions.
    Just put a big try/catch on your whole method if you still want to use the checked exception in order to avoid having tons of catch with new MyException(e).

    Comment


    • #3
      The transactional proxy is not used in your configuration.

      This happens since you call "updateSmocksEmailCount" from within the same class. So the method call does not pass the proxy and no interception can happen. This is a known issue with Spring.

      Calling your "updateSmocksEmailCount"-method from without should result as expected (incl. rollback-behaviour).

      Try to configure the "performActivity"-method in your proxy-configuration, this should help, too.

      Comment


      • #4
        Spring's Declarative Transaction - is not rolling back

        Hi Costin ,
        Thanx for your reply . The log trace is

        updateSmocksEmailCount(SmockRequest, String) - start
        13:23:28,671 DEBUG ReminderManagerImpl:? - updateSmocksEmailCount(SmockRequest, String) - start
        13:23:28,671 DEBUG ReminderManagerImpl:? - getEsdUserDAO() - start
        13:23:28,671 DEBUG ReminderManagerImpl:? - getEsdUserDAO() - start
        13:23:28,671 DEBUG ReminderManagerImpl:? - getEsdUserDAO() - end
        13:23:28,671 DEBUG ReminderManagerImpl:? - getEsdUserDAO() - end
        13:23:28,671 INFO EsdUserDAOHibImpl:? - @@@In DAOImpl
        13:23:28,671 DEBUG SessionFactoryUtils:327 - Opening Hibernate Session
        13:23:28,671 DEBUG SessionImpl:229 - opened session
        13:23:28,687 DEBUG Cascades:525 - id unsaved-value: null
        13:23:28,687 DEBUG AbstractSaveEventListener:412 - detached instance of: qc.esd.model.bo.SmockRequest
        13:23:28,687 DEBUG DefaultSaveOrUpdateEventListener:200 - updating detached instance
        13:23:28,687 DEBUG DefaultSaveOrUpdateEventListener:246 - updating [qc.esd.model.bo.SmockRequest#23]
        13:23:28,687 DEBUG DefaultSaveOrUpdateEventListener:293 - updating [qc.esd.model.bo.SmockRequest#23]
        13:23:28,687 DEBUG HibernateTemplate:248 - Eagerly flushing Hibernate session
        13:23:28,687 DEBUG AbstractFlushingEventListener:52 - flushing session
        13:23:28,687 DEBUG AbstractFlushingEventListener:102 - processing flush-time cascades
        13:23:28,687 DEBUG AbstractFlushingEventListener:150 - dirty checking collections
        13:23:28,703 DEBUG AbstractFlushingEventListener:167 - Flushing entities and processing referenced collections
        13:23:28,703 DEBUG DefaultFlushEntityEventListener:121 - Updating entity: [qc.esd.model.bo.SmockRequest#23]
        13:23:28,703 DEBUG AbstractFlushingEventListener:203 - Processing unreferenced collections
        13:23:28,703 DEBUG AbstractFlushingEventListener:217 - Scheduling collection removes/(re)creates/updates
        13:23:28,703 DEBUG AbstractFlushingEventListener:79 - Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects
        13:23:28,703 DEBUG AbstractFlushingEventListener:85 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
        13:23:28,703 DEBUG Printer:83 - listing entities:
        13:23:28,703 DEBUG Printer:90 - qc.esd.model.bo.SmockRequest{objSmockStatus=qc.esd .model.bo.SmockStatus#4, pickUpDate=null, receivedDate=05 September 2005, specialRequest=Another for the guest, qtyMissing=1, paidDate=null, requestId=23, smockSize=XXL, approvedBy=null, qtyOrdered=null, qbsPhPeople=qc.esd.model.bo.QbsPhPeople#242752, color=qc.esd.model.bo.SmockColor#3, qtyPaid=null, receivedBy=null, orderStatus=A, patchName=Guru, approvedToOrder=null, pickedUpBy=null, emailCount=2, returnedDate=null, orderDate=null, qtyRequested=2, qtyReturned=1, requestDate=09 September 2005}
        13:23:28,703 DEBUG AbstractFlushingEventListener:267 - executing flush
        13:23:28,703 DEBUG BasicEntityPersister:1910 - Updating entity: [qc.esd.model.bo.SmockRequest#23]
        13:23:28,703 DEBUG AbstractBatcher:258 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
        13:23:28,703 DEBUG AbstractBatcher:379 - opening JDBC connection
        13:23:28,703 DEBUG SQL:292 - update SMOCK_REQUEST set PATCH_NAME=?, SMOCK_SIZE=?, QTY_REQUESTED=?, SPECIAL_REQUEST=?, REQUEST_DATE=?, APPROVED_BY=?, ORDER_STATUS=?, APPROVED_TO_ORDER=?, ORDER_DATE=?, QTY_ORDERED=?, RECEIVED_DATE=?, RECEIVED_BY=?, PICK_UP_DATE=?, PICKED_UP_BY=?, RETURNED_DATE=?, QTY_RETURNED=?, PAID_DATE=?, QTY_PAID=?, QTY_MISSING=?, EMAIL_COUNT=?, SMOCK_STATUS_ID=?, PH_PEOPLE_ID=?, COLOR_ID=? where REQUEST_ID=?
        13:23:28,703 DEBUG AbstractBatcher:343 - preparing statement
        13:23:28,718 DEBUG BasicEntityPersister:1587 - Dehydrating entity: [qc.esd.model.bo.SmockRequest#23]
        13:23:28,718 DEBUG StringType:59 - binding 'Guru' to parameter: 1
        13:23:28,718 DEBUG StringType:59 - binding 'XXL' to parameter: 2
        13:23:28,718 DEBUG LongType:59 - binding '2' to parameter: 3
        13:23:28,718 DEBUG StringType:59 - binding 'Another for the guest' to parameter: 4
        13:23:28,718 DEBUG DateType:59 - binding '09 September 2005' to parameter: 5
        13:23:28,718 DEBUG StringType:52 - binding null to parameter: 6
        13:23:28,718 DEBUG StringType:59 - binding 'A' to parameter: 7
        13:23:28,718 DEBUG StringType:52 - binding null to parameter: 8
        13:23:28,718 DEBUG DateType:52 - binding null to parameter: 9
        13:23:28,718 DEBUG LongType:52 - binding null to parameter: 10
        13:23:28,734 DEBUG DateType:59 - binding '05 September 2005' to parameter: 11
        13:23:28,734 DEBUG StringType:52 - binding null to parameter: 12
        13:23:28,734 DEBUG DateType:52 - binding null to parameter: 13
        13:23:28,734 DEBUG StringType:52 - binding null to parameter: 14
        13:23:28,734 DEBUG DateType:52 - binding null to parameter: 15
        13:23:28,734 DEBUG LongType:59 - binding '1' to parameter: 16
        13:23:28,734 DEBUG DateType:52 - binding null to parameter: 17
        13:23:28,734 DEBUG LongType:52 - binding null to parameter: 18
        13:23:28,734 DEBUG LongType:59 - binding '1' to parameter: 19
        13:23:28,734 DEBUG LongType:59 - binding '2' to parameter: 20
        13:23:28,734 DEBUG Cascades:525 - id unsaved-value: null
        13:23:28,734 DEBUG LongType:59 - binding '4' to parameter: 21
        13:23:28,734 DEBUG Cascades:525 - id unsaved-value: null
        13:23:28,750 DEBUG LongType:59 - binding '242752' to parameter: 22
        13:23:28,750 DEBUG LongType:59 - binding '3' to parameter: 23
        13:23:28,750 DEBUG LongType:59 - binding '23' to parameter: 24
        13:23:28,750 DEBUG AbstractBatcher:27 - Adding to batch
        13:23:28,750 DEBUG AbstractBatcher:54 - Executing batch size: 1
        13:23:28,750 DEBUG AbstractBatcher:80 - success of batch update unknown: 0
        13:23:28,750 DEBUG AbstractBatcher:266 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
        13:23:28,750 DEBUG AbstractBatcher:363 - closing statement
        13:23:28,750 DEBUG AbstractFlushingEventListener:294 - post flush
        13:23:28,750 DEBUG SessionFactoryUtils:773 - Closing Hibernate Session
        13:23:28,750 DEBUG SessionImpl:246 - closing session
        13:23:28,750 DEBUG AbstractBatcher:394 - closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)
        13:23:28,765 DEBUG JDBCContext:213 - after transaction completion
        13:23:28,765 DEBUG SessionImpl:353 - after transaction completion
        13:23:28,765 DEBUG ESDUtil:? - getValue(String, String) - start
        13:23:28,765 DEBUG ESDUtil:? - getValue(String, String) - start
        13:23:28,765 DEBUG ESDUtil:? - getValue(String, String) - end
        13:23:28,765 DEBUG ESDUtil:? - getValue(String, String) - end
        13:23:28,765 DEBUG SessionFactoryUtils:327 - Opening Hibernate Session
        13:23:28,765 DEBUG SessionImpl:229 - opened session
        13:23:28,765 DEBUG SessionImpl:768 - find: SELECT bl FROM BuildingLocation bl WHERE bl.locationName=:locationName
        13:23:28,765 DEBUG QueryParameters:207 - named parameters: {locationName=BB}
        13:23:28,765 DEBUG QueryTranslatorImpl:113 - compile() : The query is already compiled, skipping...
        13:23:28,765 DEBUG AbstractBatcher:258 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
        13:23:28,765 DEBUG AbstractBatcher:379 - opening JDBC connection
        13:23:28,765 DEBUG SQL:292 - select buildinglo0_.LOC_ID as LOC1_, buildinglo0_.LOCATION_NAME as LOCATION2_1_, buildinglo0_.OFFICE_SITE as OFFICE3_1_, buildinglo0_.LOC_DESC as LOC4_1_, buildinglo0_.RECEPTIONIST_PHONENO as RECEPTIO5_1_, buildinglo0_.NOTES as NOTES1_ from BUILDING_LOCATION buildinglo0_ where (buildinglo0_.LOCATION_NAME=?)
        13:23:28,765 DEBUG AbstractBatcher:343 - preparing statement
        13:23:28,781 DEBUG QueryLoader:228 - bindNamedParameters() BB -> locationName [1]
        13:23:28,781 DEBUG StringType:59 - binding 'BB' to parameter: 1
        13:23:28,781 DEBUG AbstractBatcher:274 - about to open ResultSet (open ResultSets: 0, globally: 0)
        13:23:28,781 DEBUG Loader:377 - processing result set
        13:23:28,781 DEBUG Loader:382 - result set row: 0
        13:23:28,781 DEBUG LongType:86 - returning '2' as column: LOC1_
        13:23:28,781 DEBUG Loader:719 - result row: EntityKey[qc.esd.model.bo.BuildingLocation#2]
        13:23:28,781 DEBUG Loader:864 - Initializing object from ResultSet: [qc.esd.model.bo.BuildingLocation#2]
        13:23:28,781 DEBUG BasicEntityPersister:1625 - Hydrating entity: [qc.esd.model.bo.BuildingLocation#2]
        13:23:28,781 DEBUG StringType:86 - returning 'BB' as column: LOCATION2_1_
        13:23:28,781 DEBUG StringType:86 - returning 'San Diego' as column: OFFICE3_1_
        13:23:28,781 DEBUG StringType:80 - returning null as column: LOC4_1_
        13:23:28,781 DEBUG StringType:80 - returning null as column: RECEPTIO5_1_
        13:23:28,781 DEBUG StringType:80 - returning null as column: NOTES1_
        13:23:28,796 DEBUG Loader:399 - done processing result set (1 rows)
        13:23:28,796 DEBUG AbstractBatcher:281 - about to close ResultSet (open ResultSets: 1, globally: 1)
        13:23:28,796 DEBUG AbstractBatcher:266 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
        13:23:28,796 DEBUG AbstractBatcher:363 - closing statement
        13:23:28,796 DEBUG Loader:450 - total objects hydrated: 1
        13:23:28,796 DEBUG TwoPhaseLoad:96 - resolving associations for [qc.esd.model.bo.BuildingLocation#2]
        13:23:28,796 DEBUG TwoPhaseLoad:167 - done materializing entity [qc.esd.model.bo.BuildingLocation#2]
        13:23:28,796 DEBUG PersistenceContext:738 - initializing non-lazy collections
        13:23:28,796 DEBUG SessionImpl:246 - closing session
        13:23:28,796 DEBUG AbstractBatcher:394 - closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)
        13:23:28,796 DEBUG JDBCContext:213 - after transaction completion
        13:23:28,796 DEBUG SessionImpl:353 - after transaction completion
        13:23:28,796 DEBUG SessionFactoryUtils:327 - Opening Hibernate Session
        13:23:28,796 DEBUG SessionImpl:229 - opened session
        13:23:28,796 DEBUG SessionImpl:768 - find: SELECT gc FROM GarmentCoordinators gc left join fetch gc.contact left join fetch gc.objLocation WHERE gc.objLocation.locId= 2
        13:23:28,796 DEBUG QueryParameters:207 - named parameters: {}
        13:23:28,796 DEBUG QueryTranslatorImpl:113 - compile() : The query is already compiled, skipping...
        13:23:28,812 DEBUG AbstractBatcher:258 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
        13:23:28,812 DEBUG AbstractBatcher:379 - opening JDBC connection
        13:23:28,812 DEBUG SQL:292 - select garmentcoo0_.GC_ID as GC1_0_, qbsphpeopl1_.PH_PEOPLE_ID as PH1_1_, buildinglo2_.LOC_ID as LOC1_2_, garmentcoo0_.CONTACT_TYPE as CONTACT2_2_0_, garmentcoo0_.GC_DESC as GC3_2_0_, garmentcoo0_.GL_FLAG as GL4_2_0_, garmentcoo0_.LOC_ID as LOC5_2_0_, garmentcoo0_.CONTACT_ID as CONTACT6_2_0_, qbsphpeopl1_.PH_NUM as PH2_3_1_, qbsphpeopl1_.PH_NAME as PH3_3_1_, qbsphpeopl1_.ACTIVE_FLAG as ACTIVE4_3_1_, qbsphpeopl1_.OFFICE_LOC as OFFICE5_3_1_, qbsphpeopl1_.EXTENSION as EXTENSION3_1_, qbsphpeopl1_.LAST_NAME as LAST7_3_1_, qbsphpeopl1_.FIRST_NAME as FIRST8_3_1_, qbsphpeopl1_.EMAIL_ADDR as EMAIL9_3_1_, qbsphpeopl1_.SUPV_PH_NUM as SUPV10_3_1_, qbsphpeopl1_.DEPT_ID as DEPT11_3_1_, qbsphpeopl1_.DEPT_DESC as DEPT12_3_1_, qbsphpeopl1_.OFFICE_SITE as OFFICE13_3_1_, qbsphpeopl1_.PAGER as PAGER3_1_, qbsphpeopl1_.CELL_PHONE as CELL15_3_1_, qbsphpeopl1_.TITLE as TITLE3_1_, buildinglo2_.LOCATION_NAME as LOCATION2_1_2_, buildinglo2_.OFFICE_SITE as OFFICE3_1_2_, buildinglo2_.LOC_DESC as LOC4_1_2_, buildinglo2_.RECEPTIONIST_PHONENO as RECEPTIO5_1_2_, buildinglo2_.NOTES as NOTES1_2_ from GARMENT_COORDINATORS garmentcoo0_, QBS_PH_PEOPLE qbsphpeopl1_, BUILDING_LOCATION buildinglo2_ where (garmentcoo0_.LOC_ID=2 and garmentcoo0_.CONTACT_ID=qbsphpeopl1_.PH_PEOPLE_ID( +) and garmentcoo0_.LOC_ID=buildinglo2_.LOC_ID(+))
        13:23:28,812 DEBUG AbstractBatcher:343 - preparing statement
        13:23:28,828 DEBUG AbstractBatcher:274 - about to open ResultSet (open ResultSets: 0, globally: 0)
        13:23:28,828 DEBUG Loader:377 - processing result set
        13:23:28,828 DEBUG Loader:382 - result set row: 0
        13:23:28,828 DEBUG LongType:86 - returning '2' as column: GC1_0_
        13:23:28,828 DEBUG LongType:86 - returning '10001' as column: PH1_1_
        13:23:28,828 DEBUG LongType:86 - returning '2' as column: LOC1_2_
        13:23:28,828 DEBUG JDBCContext:247 - running Session.finalize()
        13:23:28,828 DEBUG Loader:719 - result row: EntityKey[qc.esd.model.bo.GarmentCoordinators#2], EntityKey[qc.esd.model.bo.QbsPhPeople#10001], EntityKey[qc.esd.model.bo.BuildingLocation#2]
        13:23:28,828 DEBUG Loader:864 - Initializing object from ResultSet: [qc.esd.model.bo.GarmentCoordinators#2]
        13:23:28,828 DEBUG BasicEntityPersister:1625 - Hydrating entity: [qc.esd.model.bo.GarmentCoordinators#2]
        13:23:28,843 DEBUG StringType:86 - returning 'P' as column: CONTACT2_2_0_
        13:23:28,843 DEBUG StringType:86 - returning 'Primary' as column: GC3_2_0_
        13:23:28,843 DEBUG StringType:86 - returning 'N' as column: GL4_2_0_
        13:23:28,843 DEBUG LongType:86 - returning '2' as column: LOC5_2_0_
        13:23:28,843 DEBUG LongType:86 - returning '10001' as column: CONTACT6_2_0_
        13:23:28,843 DEBUG Loader:864 - Initializing object from ResultSet: [qc.esd.model.bo.QbsPhPeople#10001]
        13:23:28,843 DEBUG BasicEntityPersister:1625 - Hydrating entity: [qc.esd.model.bo.QbsPhPeople#10001]
        13:23:28,843 DEBUG LongType:86 - returning '10001' as column: PH2_3_1_
        13:23:28,843 DEBUG StringType:86 - returning 'Harisha, Mallegowda' as column: PH3_3_1_
        13:23:28,843 DEBUG StringType:86 - returning 'Y' as column: ACTIVE4_3_1_
        13:23:28,843 DEBUG StringType:86 - returning 'M-170' as column: OFFICE5_3_1_
        13:23:28,859 DEBUG StringType:86 - returning '77652' as column: EXTENSION3_1_
        13:23:28,859 DEBUG StringType:86 - returning 'Harisha' as column: LAST7_3_1_
        13:23:28,859 DEBUG StringType:86 - returning 'Mallegowda' as column: FIRST8_3_1_
        13:23:28,859 DEBUG StringType:86 - returning 'c_hmalle' as column: EMAIL9_3_1_
        13:23:28,859 DEBUG LongType:86 - returning '2957' as column: SUPV10_3_1_
        13:23:28,859 DEBUG StringType:86 - returning '4710' as column: DEPT11_3_1_
        13:23:28,859 DEBUG StringType:86 - returning '4710 - QWBS Repair Center' as column: DEPT12_3_1_
        13:23:28,859 DEBUG StringType:86 - returning 'San Diego' as column: OFFICE13_3_1_
        13:23:28,859 DEBUG StringType:86 - returning '206147' as column: PAGER3_1_
        13:23:28,859 DEBUG StringType:86 - returning '4049206147' as column: CELL15_3_1_
        13:23:28,859 DEBUG StringType:80 - returning null as column: TITLE3_1_
        13:23:28,859 DEBUG Loader:864 - Initializing object from ResultSet: [qc.esd.model.bo.BuildingLocation#2]
        13:23:28,859 DEBUG BasicEntityPersister:1625 - Hydrating entity: [qc.esd.model.bo.BuildingLocation#2]
        13:23:28,875 DEBUG StringType:86 - returning 'BB' as column: LOCATION2_1_2_
        13:23:28,875 DEBUG StringType:86 - returning 'San Diego' as column: OFFICE3_1_2_
        13:23:28,875 DEBUG StringType:80 - returning null as column: LOC4_1_2_
        13:23:28,875 DEBUG StringType:80 - returning null as column: RECEPTIO5_1_2_
        13:23:28,875 DEBUG StringType:80 - returning null as column: NOTES1_2_
        13:23:28,875 DEBUG Loader:399 - done processing result set (1 rows)
        13:23:28,875 DEBUG AbstractBatcher:281 - about to close ResultSet (open ResultSets: 1, globally: 1)
        13:23:28,875 DEBUG AbstractBatcher:266 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
        13:23:28,875 DEBUG AbstractBatcher:363 - closing statement
        13:23:28,875 DEBUG Loader:450 - total objects hydrated: 3
        13:23:28,875 DEBUG TwoPhaseLoad:96 - resolving associations for [qc.esd.model.bo.GarmentCoordinators#2]
        13:23:28,875 DEBUG DefaultLoadEventListener:193 - loading entity: [qc.esd.model.bo.BuildingLocation#2]
        13:23:28,875 DEBUG DefaultLoadEventListener:209 - entity found in session cache
        13:23:28,875 DEBUG DefaultLoadEventListener:326 - attempting to resolve: [qc.esd.model.bo.BuildingLocation#2]
        13:23:28,875 DEBUG DefaultLoadEventListener:335 - resolved object in session cache: [qc.esd.model.bo.BuildingLocation#2]
        13:23:28,890 DEBUG DefaultLoadEventListener:193 - loading entity: [qc.esd.model.bo.QbsPhPeople#10001]
        13:23:28,890 DEBUG DefaultLoadEventListener:209 - entity found in session cache
        13:23:28,890 DEBUG DefaultLoadEventListener:326 - attempting to resolve: [qc.esd.model.bo.QbsPhPeople#10001]
        13:23:28,890 DEBUG DefaultLoadEventListener:335 - resolved object in session cache: [qc.esd.model.bo.QbsPhPeople#10001]
        13:23:28,890 DEBUG TwoPhaseLoad:167 - done materializing entity [qc.esd.model.bo.GarmentCoordinators#2]
        13:23:28,890 DEBUG TwoPhaseLoad:96 - resolving associations for [qc.esd.model.bo.QbsPhPeople#10001]
        13:23:28,890 DEBUG TwoPhaseLoad:167 - done materializing entity [qc.esd.model.bo.QbsPhPeople#10001]
        13:23:28,890 DEBUG TwoPhaseLoad:96 - resolving associations for [qc.esd.model.bo.BuildingLocation#2]
        13:23:28,890 DEBUG TwoPhaseLoad:167 - done materializing entity [qc.esd.model.bo.BuildingLocation#2]
        13:23:28,890 DEBUG PersistenceContext:738 - initializing non-lazy collections
        13:23:28,921 DEBUG HibernateTemplate:248 - Eagerly flushing Hibernate session
        13:23:28,921 DEBUG AbstractFlushingEventListener:52 - flushing session
        13:23:28,921 DEBUG AbstractFlushingEventListener:102 - processing flush-time cascades
        13:23:28,921 DEBUG AbstractFlushingEventListener:150 - dirty checking collections
        13:23:28,921 DEBUG AbstractFlushingEventListener:167 - Flushing entities and processing referenced collections
        13:23:28,921 DEBUG AbstractFlushingEventListener:203 - Processing unreferenced collections
        13:23:28,921 DEBUG AbstractFlushingEventListener:217 - Scheduling collection removes/(re)creates/updates
        13:23:28,937 DEBUG AbstractFlushingEventListener:79 - Flushed: 0 insertions, 0 updates, 0 deletions to 3 objects
        13:23:28,937 DEBUG AbstractFlushingEventListener:85 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
        13:23:28,937 DEBUG Printer:83 - listing entities:
        13:23:28,937 DEBUG Printer:90 - qc.esd.model.bo.GarmentCoordinators{contact=qc.esd .model.bo.QbsPhPeople#10001, gcId=2, glFlag=N, contactType=P, gcDesc=Primary, objLocation=qc.esd.model.bo.BuildingLocation#2}
        13:23:28,937 DEBUG Printer:90 - qc.esd.model.bo.BuildingLocation{officeSite=San Diego, locationName=BB, receptionistPhoneno=null, locDesc=null, locId=2, notes=null}
        13:23:28,937 DEBUG Printer:90 - qc.esd.model.bo.QbsPhPeople{pager=206147, phName=Harisha, Mallegowda, extension=77652, supvPhNum=2957, phPeopleId=10001, title=null, activeFlag=Y, firstName=Mallegowda, cellPhone=4049206147, lastName=Harisha, officeSite=San Diego, officeLoc=M-170, emailAddr=c_hmalle, deptDesc=4710 - QWBS Repair Center, phNum=10001, deptId=4710}
        13:23:28,937 DEBUG AbstractFlushingEventListener:267 - executing flush
        13:23:28,937 DEBUG AbstractFlushingEventListener:294 - post flush
        13:23:28,937 DEBUG SessionFactoryUtils:773 - Closing Hibernate Session
        13:23:28,937 DEBUG SessionImpl:246 - closing session
        13:23:28,937 DEBUG AbstractBatcher:394 - closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)
        13:23:28,937 DEBUG JDBCContext:213 - after transaction completion
        13:23:28,937 DEBUG SessionImpl:353 - after transaction completion
        13:23:28,937 DEBUG ESDUtil:? - getValue(String, String) - start
        13:23:28,937 DEBUG ESDUtil:? - getValue(String, String) - start
        13:23:28,937 DEBUG ESDUtil:? - getValue(String, String) - end
        13:23:28,937 DEBUG ESDUtil:? - getValue(String, String) - end
        13:23:28,937 DEBUG ESDUtil:? - getValue(String, String) - start
        13:23:28,937 DEBUG ESDUtil:? - getValue(String, String) - start
        13:23:28,937 DEBUG ESDUtil:? - getValue(String, String) - end
        13:23:28,937 DEBUG ESDUtil:? - getValue(String, String) - end
        13:23:28,937 DEBUG ReminderManagerImpl:? - sendMail(String, List, String, String, String, File) - start
        13:23:28,937 DEBUG ReminderManagerImpl:? - sendMail(String, List, String, String, String, File) - start
        13:23:28,937 DEBUG ReminderManagerImpl:? - i am in before cc is [Ljava.lang.String;@d03350
        13:23:28,937 DEBUG ReminderManagerImpl:? - i am in before cc is [Ljava.lang.String;@d03350
        13:23:28,937 DEBUG ReminderManagerImpl:? - i am in after
        13:23:28,937 DEBUG ReminderManagerImpl:? - i am in after
        13:23:30,000 ERROR ReminderManagerImpl:? - org.springframework.mail.MailSendException: Could not send mails: Invalid Addresses;
        nested exception is:
        class com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <[email protected]>... User unknown
        ;
        nested exception is:
        class com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <[email protected]>... User unknown

        13:23:30,000 ERROR ReminderManagerImpl:? - org.springframework.mail.MailSendException: Could not send mails: Invalid Addresses;
        nested exception is:
        class com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <[email protected]>... User unknown
        ;
        nested exception is:
        class com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <[email protected]>... User unknown

        13:23:30,000 ERROR ReminderManagerImpl:? - qc.esd.model.exception.ReminderActionFailedExcepti on: Could not send mails: Invalid Addresses;
        nested exception is:
        class com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <[email protected]>... User unknown
        ;
        nested exception is:
        class com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <[email protected]>... User unknown

        13:23:30,000 ERROR ReminderManagerImpl:? - qc.esd.model.exception.ReminderActionFailedExcepti on: Could not send mails: Invalid Addresses;
        nested exception is:
        class com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <[email protected]>... User unknown
        ;
        nested exception is:
        class com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <[email protected]>... User unknown


        After looking at log trace , i think it is not using transaction at all . For quering on Database update/insert or select it is opening new session . Also exception is being caught and logged correctly .
        I am using Oravle 9i.


        3. your code could use some refactoring - there is no point in using checked exceptions; there are very good threads about unchecked exception
        I have heard about Spring's style of Error Handling . Can you please give me some good URL to read it from . It will be very helpful if you give some links.


        Thanks ,
        Vaibhav

        Comment


        • #5
          HI SotA
          Thanx for your input . Is it bug ? Now i changed my conig file . It is like this



          <bean id="ReminderManager"
          class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
          <property name="transactionManager"><ref local="ReminderTransactionManager"/></property>
          <property name="target"><ref local="ReminderManagerTarget"/></property>
          <property name="transactionAttributes">
          <props>
          <prop key="updateSmocksEmailCount">PROPAGATION_REQUIRED,-qc.esd.model.exception.ReminderActionFailedExcepti on</prop>
          </props>
          </property>
          </bean>

          <bean id="ReminderManagerTarget" class="qc.esd.model.service.impl.ReminderManagerIm pl">
          <property name="mailSender">
          <ref bean="MAIL_SENDER"/>
          </property>
          <property name="esdUserDAO">
          <ref bean="ESDUSER_DAO"/>
          </property>
          <property name="esdAdminDAO">
          <ref bean="ESDADMIN_DAO"/>
          </property>
          <property name="from">
          <value>[email protected]</value>
          </property>

          </bean>


          <bean id="ReminderManagerActivity" class="qc.esd.model.service.impl.ReminderManagerIm pl">
          <property name="mailSender">
          <ref bean="MAIL_SENDER"/>
          </property>
          <property name="esdUserDAO">
          <ref bean="ESDUSER_DAO"/>
          </property>
          <property name="esdAdminDAO">
          <ref bean="ESDADMIN_DAO"/>
          </property>
          <property name="from">
          <value>[email protected]</value>
          </property>
          <property name="reminderManager">
          <ref bean="ReminderManager"/>
          </property>

          </bean>


          and i changed my performActivity method slightly .

          It is now like this : --

          reminderManager.updateSmocksEmailCount(smockReques t,
          ESDConstants.IN_ACTIVE);

          And best part of it is declarative transaction is working correctly .

          Thanx once again .

          Vaibhav

          Comment


          • #6
            No, this is not a bug.
            It is a direct result of the proxy-based AOP-approach Spring is using.

            Most of the times this is sufficient, because most often your Service-/Manager-Layer will be called from "outside" (Web-Controller/-Action or testcode), so the transactional proxy will be used.

            You may rewrite your configuration by making the performActivity-operation transactional:
            Code:
             <bean id="ReminderManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
              <property name="transactionManager"><ref local="ReminderTransactionManager"/></property>
              <property name="target"><ref local="ReminderManagerTarget"/></property>
              <property name="transactionAttributes">
                <props>
                  <prop key="performActivity">PROPAGATION_REQUIRED</prop>
                </props>
              </property>
            </bean>
            Of course I don't know, if this is ok for your use case.

            Comment


            • #7
              Hi
              SotA,

              You may rewrite your configuration by making the performActivity-operation transactional
              Thanx for your suggestion. But i can't make performActivity method trnasactional. As i wrote before my trnasactional method is called in loop. I don't want to roll back all database changes . I just want to roll back database changes for which mail sending is failed.
              Can you please give me some link describing Spring's AOP support.


              Thanks,
              Vaibhav

              Comment


              • #8
                But i can't make performActivity method trnasactional. As i wrote before my trnasactional method is called in loop.
                Ohm, sorry. I missed that point ;-)

                I can't provide you a direct link to documents about Spring AOP, but there is a chapter in Springs Reference Documentation, although I am not sure, if there is a discussion about the drawbacks of the proxy-based approach.

                You should search this forum (Data Access) about Transactions and proxy-based AOP, since this has been explained several times now.

                Comment

                Working...
                X