use of com.haulmont.cuba.core.TransactionalDataManager in project cuba by cuba-platform.
the class BulkEditorDataServiceBean method loadItemsWithCompositeKey.
@SuppressWarnings("unchecked")
protected List<Entity> loadItemsWithCompositeKey(LoadDescriptor ld) {
Preconditions.checkNotNull(ld.getMetaClass(), "metaClass is null");
TransactionalDataManager secureDataManager = txDataManager.secure();
String storeName = metadataTools.getStoreName(ld.getMetaClass());
if (storeName == null) {
storeName = Stores.MAIN;
}
List<Entity> items;
try (Transaction tx = persistence.createTransaction(storeName)) {
// for composite key we can only load with N queries, since IN operator is not supported for composite keys
items = ld.getSelectedItems().stream().map(item -> secureDataManager.load(Id.of(item)).view(ld.getView()).softDeletion(false).dynamicAttributes(ld.isLoadDynamicAttributes()).optional()).filter(Optional::isPresent).map(o -> (Entity) o.get()).collect(Collectors.toList());
tx.commit();
}
return items;
}
Aggregations