spring-framework / org.springframework.test.annotation / Commit

Commit

@Target([AnnotationTarget.CLASS, AnnotationTarget.FILE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]) @Inherited @Rollback(false) class Commit

@Commit is a test annotation that is used to indicate that a test-managed transaction should be committed after the test method has completed.

Consult the class-level Javadoc for org.springframework.test.context.transaction.TransactionalTestExecutionListener for an explanation of test-managed transactions.

When declared as a class-level annotation, @Commit defines the default commit semantics for all test methods within the test class hierarchy. When declared as a method-level annotation, @Commit defines commit semantics for the specific test method, potentially overriding class-level default commit or rollback semantics.

Warning: @Commit can be used as direct replacement for @Rollback(false); however, it should not be declared alongside @Rollback. Declaring @Commit and @Rollback on the same test method or on the same test class is unsupported and may lead to unpredictable results.

Author
Sam Brannen

Since
4.2

See Also
Rollbackorg.springframework.test.context.transaction.TransactionalTestExecutionListener

Constructors

<init>

Commit()

@Commit is a test annotation that is used to indicate that a test-managed transaction should be committed after the test method has completed.

Consult the class-level Javadoc for org.springframework.test.context.transaction.TransactionalTestExecutionListener for an explanation of test-managed transactions.

When declared as a class-level annotation, @Commit defines the default commit semantics for all test methods within the test class hierarchy. When declared as a method-level annotation, @Commit defines commit semantics for the specific test method, potentially overriding class-level default commit or rollback semantics.

Warning: @Commit can be used as direct replacement for @Rollback(false); however, it should not be declared alongside @Rollback. Declaring @Commit and @Rollback on the same test method or on the same test class is unsupported and may lead to unpredictable results.