Skip to content

EntityManager#find after EntityManager#flush does not work #13

@antidote2

Description

@antidote2

I constructed a simple example:

The test passes with @transactional(TransactionMode.DISABLED) or fails with COMMIT at the assert line

Could you please explain what happens under the hood leading to this condition.

TEST

@Test
@Transactional(TransactionMode.COMMIT)
public void testExample() {
    B2BReader b2BReader = readerTestDataFactory.loadActiveB2BReader();
    b2BReaderRepository.example(b2BReader);
}

METHOD UNDER TEST

public void example(final B2BReader b2BReader) {
    em.createQuery("UPDATE B2BReader SET externalId = 1000 WHERE b2bReaderId = :id").setParameter("id", b2BReader.getB2bReaderId()).executeUpdate();
    em.flush();
    B2BReader freshB2BReader = em.find(B2BReader.class, b2BReader.getB2bReaderId());
    assert freshB2BReader.getExternalId() == 1000;
}

Last arquillian release version on wildfly 8, last arquillian-extension-transaction version, hibernate 4.3.5

Best Regards!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions