Re: Cayenne callback listener in single transaction

Aristedes Maniatis <[email protected]>
Newsgroups gmane.comp.java.cayenne.devel
Message-ID <[email protected]>
On 19/12/19 1:18am, Artem Kravchenko wrote:
> So the problem which I faced with: the commits (main one and 
> subsequent from listener) are two different jdbs transaction, which is 
> reasonable in fact. But in such case the data consistency is not 
> guaranteed - second commit might be failed. It is really important for me.


At first glance, I cannot understand why wrapping them in a single 
transaction would not be the default behaviour here. Adding records in 
@PostPersist is likely something like:

* audit records to track changes

* financial transactional data (eg writing to a general ledger when 
invoice is created)

* updating denormalised data (eg. contact.owing) which might be done for 
search or performance reasons.


In each case I can think of, rolling back the whole transaction would be 
a more appropriate behaviour in case of failure.


Cheers

Ari
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.