Issue with using Transactional annotation

Hi!
I’ve got a strange issue in my project based on Cuba Platform 7.2.13.
There is a data loader delegate method in the browse screen controller in the web module

@Inject
private BalanceService balanceService;

@Install(to = “balanceDl”, target = Target.DATA_LOADER)
public List balanceDlLoadDelegate(LoadContext context) {

return new ArrayList<>(balanceService.getBalanceByDate(calcDate));
}

Interface BalanceService is defined in the global module.
Implementation bean BalanceServiceBean is defined in the core module and returns Set of non-persistent entities. In the implementation bean there are several JPQL-queries, and the issue is that I can’t use Transactional annotation in methods which provide queries. When I use Transactional, I receive an exception:
com.haulmont.cuba.core.global.RemoteException: No active transaction on persistence.getEntityManager() invocation.
But if I use

try (Transaction tx = persistence.getTransaction()) {
EntityManager em = persistence.getEntityManager();

}

it works correct.
What’s wrong with using of the Transactional annotation in this bean? In other spring beans in the core module it works fine.

Hi,
The frequently encountered problem is that @Transactional works only when you call this method from another bean, not from the other method of the same bean. I guess it’s your case.

See Declarative Transaction Management - CUBA Platform. Developer’s Manual

Additionally, keep in mind that declarative markup will only work if the method is called by the container, i.e. calling a transaction method from another method of the same object will not start a transaction.

Hi!
You’re right, that is my case.
Thank you