jakarta-eejtawildfly-10deltaspikedeltaspike-jpa

Wildfly - deltaspike - transaction not committed?


I am using Wildfly 10 along with Deltaspike and having issues persisting an entity. The problem comes later on when I try to refresh it or persist another entity referring to it. When I try to refresh it, I get the exception indicating the entity is not managed. If I try to persist another entity referencing it, that is when I get the exception indicating the entity is in a transient state.

I'm using JTA and the entity should have been committed earlier as it was saved in another method call.

I have tried using Container Managed Transactions and Bean Managed Transactions. On that note, it appears that only the apache-deltaspike.properties file has any effect on changing that. I have also manually enabled the transaction interceptor, but I don't believe that makes a difference because it is enabled with or without explicitly activating it in beans.xml. The @Transactional annotation doesn't seem to actually commit the transaction (I tested using various arguments to it and I would have expected a different exception, but just go the same one).

@Transactional(Transactional.TxType.REQUIRES_NEW)
//@Transactional(Transactional.TxType.NEVER)
@Loggable
protected void startSession() {
    entity = new Entity("something");
    LOGGER.warn("entity:" + entity);
    entityRepository.saveAndFlushAndRefresh(entity);

    LOGGER.warn("end - entity:" + entity.getId());
}

The log statements show the id is 0, unset. Now, if I query the sequence, I see it is at 189 from being hit so many times ...

The actual exception is when I try to do:

entityRepository.refresh(entity);

That is when I get the exception indicating the entity is not managed. As I indicated, I can see the Transaction Interceptor is activated according to the logs.

Any ideas?


Solution

  • The problem appears to be in newer versions of hibernate, you cannot use a primitive type for the id / version fields.

    I am now able to save entities.