arquillian / arquillian-extension-transaction

9 stars 10 forks source link

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

Open antidote2 opened 8 years ago

antidote2 commented 8 years ago

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!

bartoszmajsak commented 7 years ago

Could you contribute this failing test as a part of a PR from which I could take over and see what's going on under the hood?

antidote2 commented 7 years ago

Unfortunately I do not work any more in that project and would need to create an EE setup with arquillian and db.

bartoszmajsak commented 7 years ago

No worries, I'll see what I can do :)