Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1024317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:45:40+00:00 2026-05-16T11:45:40+00:00

We have implemented JUnit4 in our application which uses Spring core & JPA with

  • 0

We have implemented JUnit4 in our application which uses Spring core & JPA with DB2.
We need to test a full functionality which retrieves data from one database and merges into another database.

Test case for retrieving the data from 1st database is written and it is running without any error perfectly but the records are not store into the 2nd database.

Implementation

The TestCase class we have included the following annotations to make the test case run under a transaction if necessary,

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
      DependencyInjectionTestExecutionListener.class,    
      TransactionalTestExecutionListener.class})
@ContextConfiguration(locations={""})
@TransactionConfiguration(transactionManager="defaultTransactionManager", defaultRollback=false)
@Transactional

In the application we have a manager class to perform this operation with doSynch() method. From that method crudHelper class’s txStore() method will be called to initialize and call doStore() method (in same class) to merge the entity to database.

Following are the transactional declarative through out this test case logic

TestCase testSynch() - @Transactional(propagation=Propagation.SUPPORTS)
Manager doSynch() - @Transactional(propagation=Propagation.NEVER)
CRUDHelper txStore() - @Transactional(propagation=Propagation.REQUIRED)
           doStore() - No Transactional annotation

doSynch() is marked as NEVER as at that point it doesn’t need any transaction and in further levels such as in CRUDHelper the transaction can be marked as REQUIRED to ensure a transaction to be available.

Problem

Here when we run the test case which calls the Manager’s doSynch() method to test the functionality, complete flow is working perfect except that records are not merged and no errors are thrown.

The Manager method when called from a JSP works great.
Also we tested by calling txStore() directly from test case and it also works fine.

Please let us know whether the transaction management is not proper or a work around to this issue will be of greater help. Also pls update me if the issue or environment is not clear. Thanks in advance.!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:45:41+00:00Added an answer on May 16, 2026 at 11:45 am

    Do you mark your methods with the @Rollback annotation?

    From the JavaDoc:

    Test annotation to indicate whether or
    not the transaction for the annotated
    test method should be rolled back
    after the test method has completed.
    If true, the transaction will be
    rolled back; otherwise, the
    transaction will be committed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.