Skip to content

TransactionRequiredException thrown although TransactionalAdvice annotated #2102

Description

@Wheedman

Expected Behavior

The deletion in the database should work as expected.

Actual Behaviour

A TransactionalRequiredException is thrown

Steps To Reproduce

  1. Use testcontainers with postgresql 11.8
  2. Write a Micronaut-Test testing the following method
    @Override
    public int deleteAllSlugsLikeAndOlderThan(String query, Instant date) {
        String qlString = "DELETE FROM ArdmResultEntity AS s WHERE s.slug LIKE CONCAT('%', ?1, '%') AND s.createdAt < ?2";
        Query query = entityManager.createQuery(qlString)
            .setParameter(1, query.trim())
            .setParameter(2, date);

        int deletedRows = 0;

        try {
            deletedRows = query.executeUpdate();
        } catch (Exception e) {
           log.error("Deletion was not successful", e);
        }
        return deletedRows;
    }
  1. TransactionRequiredException is thrown

Environment Information

No response

Example Application

No response

Version

3.5.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions