Is @PostRemove out of a transaction?

I found the following information from the spec. But for me it is not clear who is not an English native.

Callback methods PostPersistand PostRemoveare called for the object after the object has been made permanent or deleted. These callbacks will also be called for all objects to which these operations are cascaded. The methods PostPersistand PostRemovewill be called after the operations of inserting and deleting the database, respectively. These database operations may occur immediately after the persist, merge, or remove operations were called, or they may occur immediately after the flush operation (which may be at the end of the transaction). The generated primary key values ​​are available in the method PostPersist.

My question is: can any transactional jobs be dropped after @PostRemove?

Let's say my entity deletes some offline files on @PostRemove

class MyEntity {

    @PostRemove
    private void onPostRemove() {
        // delete offline files related to this entity
        // not restorable!
    }
}

, , ? (?)

+4
2

, , , entites db . @PostRemove .

, , , , commit() . , , , , , . .

to_be_deleted db. . , commit() .

, Java EE, CDI jca. Spring, TransactionSynchronizationAdapter . .

+3

.

(EntityManager#flush()), . Post .

+1

Source: https://habr.com/ru/post/1648998/


All Articles