You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@deltaspike.apache.org by Alex Roytman <ro...@gmail.com> on 2019/10/22 16:58:34 UTC
@Transactional not starting transaction in some cases?
Hi,
I am using Weld (3.1.2) and Deltaspike (1.9.1) to drive Eclipselink JPA
(2.7.5)
My EntityManager producer produces request scoped entity managers
@Produces
@RequestScoped
protected EntityManager createEntityManager() {
return entityManagerFactory.createEntityManager();
}
I have a case where transaction is not getting started on @ApplicationScope
bean:
public MyBean{
@Inject private EntityManager em;
public void methodA{
....
try{
methodB()
} catch {
// perform non DB rollback logic here
}
@Transactional
public void methodB{
//obtain and manipulate entities via em instance
// checking em.getTransaction().isActive() returns false
}
}
method methodA() gets called from Jersey resource
if I annotate the top level method methodA as @Transactional everything
works however when methodB is annotated and called from methodA no
transaction is started
while my usage is a bit fishy (what if transaction is started before
calling methodA but it works for this particular case and I have checks
for it not to be ran in existing transaction) still I would expect methodB
to start transaction.
Any suggestions is appreciated.
Thank you,
alex