This is quite surprising for me: calling @Transactional method of the same class should work. Because, I have usually observed that it doesn't work and usually I have to refactor the @Transactional method out of the class and put in some other class(which has guice @Singleton of course), and then injecting this new class to caller class just to make Transaction work. And yes, guice is giving tough time with @Transactional as there is no proper way of finding out if it is working fine(other than updating DB directly)
On Wednesday, 26 June 2019 15:51:43 UTC+5:30, Thomas Broyer wrote: > > > > On Wednesday, June 26, 2019 at 9:10:24 AM UTC+2, Kasper Nielsen wrote: >> >> > >> > though generally-speaking I avoid Guice Persist in new projects; if >> only because there's no validation that @Transactional is correctly applied >> and will have any effect (and we've had bugs because of that: @Transaction >> on private methods for example, or sometimes in classes that weren't >> instantiated by Guice). >> Do you use an alternative implementation? Or do you manual handle the >> transactions? >> > > I'm using jOOQ (and was using guice-jooq-persist), so I just use jOOQ's > transaction management methods ( > https://www.jooq.org/doc/3.11/manual/sql-execution/transaction-management/), > that we wrap into a simple TransactionManager so the jOOQ types aren't > directly exposed to our non-DAO code. > From: > doInTransaction(); > // … > @Transactional void doInTransaction() { … } > > to: > transactionManager.transaction(this::doInTransaction); > // … > private void doInTransaction() { … } > > (or we could have inlined the doInTransaction method into a lambda) > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-guice. To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/e0676d73-8363-4161-8e68-5836ac982c11%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
