Hello! We use Cuba Platform v 7.2 and PostgreSql we have two DB servers master and replics. In some services we decided to read data from the replica . For this purpose we created additional dataStore and persistent.xml - that doesn’t contains entities. Implement our DataManager with only one methods loadList(LoadContext context). When we invoke the method we get the exception
Cannot handle entity from _MAIN_ datastore because active transaction is for TestDbSource
Could you please help us avoid this exception or suggest any other ways to make reading entities from another DB. Thank you in advance.
Our DataManagerImpl:
@Service(CustomDataManagerService.NAME)
public class CustomDataManagerServiceBean implements CustomDataManagerService {
private static final Logger log = LoggerFactory.getLogger(DataManagerBean.class);
@Inject
protected StoreFactory storeFactory;
@Override
public <E extends Entity> List<E> loadList(LoadContext<E> context) {
DataStore storage = storeFactory.get("TestDbSource");
context.setJoinTransaction(true);
List<E> entities = storage.loadList(context);
return entities;
}
}