CAP: невозможно получить поля сущности составного объекта в com.sap.cds.ql.Predicate с помощью запроса CQL.JAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 CAP: невозможно получить поля сущности составного объекта в com.sap.cds.ql.Predicate с помощью запроса CQL.

Сообщение Anonymous »

У меня есть объект базы данных под названием ComplaintTypeConfigurations, как показано ниже.

Код: Выделить всё

entity ComplaintTypeConfigurations : cuid, managed {
identifier                       : DataType.Identifier;
complaintCategory                : ComplaintCategory;
code                             : DataType.Code;
description                      : localized DataType.Description;
individualComplaintType          : DataType.Flag default false;
itemCategory                     : ItemCategory;
complaintTypeToSalesAreaMappings : Composition of many ComplaintTypeToSalesAreaMappings
on complaintTypeToSalesAreaMappings.complaintTypeConfiguration = $self;
numberRange                      : NumberRange; //deprecated
isActive                         : Boolean default true;
currentNumber                    : DataType.CurrentNumber;  //deprecated
}
Здесь у нас есть составное отношение к complaintTypeToSalesAreaMappings, под которым есть поля SalesOrganization, Distributionchannel и Division, как показано ниже.

Код: Выделить всё

entity ComplaintTypeToSalesAreaMappings : cuid, managed {
salesOrganization          : SalesOrganization;
distributionChannel        : DistributionChannel;
division                   : Division;
complaintTypeConfiguration : ComplaintTypeConfiguration;
}
Теперь я хотел бы запросить продажи/дистрибуцию/подразделение, используя предикаты, как показано ниже.

Код: Выделить всё

Predicate predicateSalesArea = CQL.get(ComplaintTypeToSalesAreaMappings.SALES_ORGANIZATION_ID).eq(salesOrganization)
.and(CQL.get(ComplaintTypeToSalesAreaMappings.DISTRIBUTION_CHANNEL_ID).isNull()
.and(CQL.get(ComplaintTypeToSalesAreaMappings.DIVISION_ID).isNull()))
.or(CQL.get(ComplaintTypeToSalesAreaMappings.SALES_ORGANIZATION_ID).eq(salesOrganization)
.and(CQL.get(ComplaintTypeToSalesAreaMappings.DISTRIBUTION_CHANNEL_ID).eq(distributionChannel)
.and(CQL.get(ComplaintTypeToSalesAreaMappings.DIVISION_ID).isNull())))
.or(CQL.get(ComplaintTypeToSalesAreaMappings.SALES_ORGANIZATION_ID).eq(salesOrganization)
.and(CQL.get(ComplaintTypeToSalesAreaMappings.DISTRIBUTION_CHANNEL_ID).eq(distributionChannel)
.and(CQL.get(ComplaintTypeToSalesAreaMappings.DIVISION_ID).eq(division))));

Predicate predicate = CQL.get(ComplaintTypeConfigurations.IS_ACTIVE).eq(true)
.and(CQL.get(ComplaintTypeConfigurations.COMPLAINT_CATEGORY_CODE).eq(complaintCategoryCode))
.and(CQL.get(ComplaintTypeConfigurations.COMPLAINT_TYPE_TO_SALES_AREA_MAPPINGS).isNull()).or(predicateSalesArea);

if(code!=null || description!=null) {

predicate.and(CQL.get(ComplaintTypeConfigurations.CODE).contains(code).and(CQL.get(ComplaintTypeConfigurations.DESCRIPTION).contains(description)));
}

CqnSelect select=Select.from(ComplaintTypeConfigurations_.class)
.columns(a->a.ID(),b->b.code(),c->c.description(),
e->e.complaintTypeToSalesAreaMappings().salesOrganization_ID(),
f->f.complaintTypeToSalesAreaMappings().distributionChannel_ID(),
g->g.complaintTypeToSalesAreaMappings().division_ID(),
h->h.individualComplaintType(),
i->i.itemCategory_ID()).where(predicate);

filteredResult=db.run(select);
Когда я запускаю этот запрос, я получаю ошибку, как показано ниже.

Код: Выделить всё

No element with name 'salesOrganization_ID' in 'CustomerConfigurationService.ComplaintTypeConfigurations' (service 'PersistenceService$Default', event 'READ', entity 'CustomerConfigurationService.ComplaintTypeConfigurations')
at com.sap.cds.services.impl.ServiceImpl.dispatch(ServiceImpl.java:256) ~[cds-services-impl-2.10.1.jar:na]
at com.sap.cds.services.impl.ServiceImpl.emit(ServiceImpl.java:177) ~[cds-services-impl-2.10.1.jar:na]
at com.sap.cds.services.ServiceDelegator.emit(ServiceDelegator.java:33) ~[cds-services-api-2.10.1.jar:na]
at com.sap.cds.services.utils.services.AbstractCqnService.run(AbstractCqnService.java:53) ~[cds-services-utils-2.10.1.jar:na]
at com.sap.cds.services.utils.services.AbstractCqnService.run(AbstractCqnService.java:43) ~[cds-services-utils-2.10.1.jar:na]
at com.sap.ic.cmh.configuration.persistency.ComplaintTypeConfigurationDao.getAllComplaintsWithWildCharacter(ComplaintTypeConfigurationDao.java:179) ~[classes/:na]
at jdk.internal.reflect.GeneratedMethodAccessor33.invoke(Unknown Source) ~[na:na]
Я не могу получить поля составной сущности. Как я могу добиться этого с помощью предикатов.
Может кто-нибудь помочь мне здесь?
Однако я могу добиться этого, используя запрос CQN, как показано ниже.

Код: Выделить всё

        filteredResult = db
.run(Select.from(ComplaintTypeConfigurations_.class)
.columns(a->a.ID(),b->b.code(),c->c.description(),
e->e.complaintTypeToSalesAreaMappings().salesOrganization_ID(),
f->f.complaintTypeToSalesAreaMappings().distributionChannel_ID(),
g->g.complaintTypeToSalesAreaMappings().division_ID(),
h->h.individualComplaintType(),
i->i.itemCategory_ID())
.where(d->d.isActive().eq(true).and(d.complaintCategory_code().eq(complaintCategoryCode).and(d.code().contains(code).or(d.description().contains(description))).and(not(d.complaintTypeToSalesAreaMappings().exists())
.or(d.complaintTypeToSalesAreaMappings().salesOrganization_ID().eq(salesOrganization)
.and(d.complaintTypeToSalesAreaMappings().distributionChannel_ID().isNull()
.and(d.complaintTypeToSalesAreaMappings().division_ID().isNull())))
.or(d.complaintTypeToSalesAreaMappings().salesOrganization_ID().eq(salesOrganization)
.and(d.complaintTypeToSalesAreaMappings().distributionChannel_ID().eq(distributionChannel)
.and(d.complaintTypeToSalesAreaMappings().division_ID().isNull())))
.or(d.complaintTypeToSalesAreaMappings().salesOrganization_ID().eq(salesOrganization)
.and(d.complaintTypeToSalesAreaMappings().distributionChannel_ID().eq(distributionChannel)
.and(d.complaintTypeToSalesAreaMappings().division_ID().eq(division))))))));
Но для моего сценария мне нужно будет изменить запрос в соответствии с определенными условиями, поэтому, используя приведенный выше запрос, я получаю несколько блоков if else с почти одинаковым запросом с небольшими изменениями полей. Поэтому мы решили использовать предикаты. Но мы не можем этого добиться.

Подробнее здесь: https://stackoverflow.com/questions/789 ... p-cds-ql-p
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Почему у меня возникает ошибка формата CDS API после CDS BETA?
    Anonymous » » в форуме Python
    0 Ответы
    10 Просмотры
    Последнее сообщение Anonymous
  • Почему у меня возникает ошибка формата CDS API после CDS BETA?
    Anonymous » » в форуме Python
    0 Ответы
    14 Просмотры
    Последнее сообщение Anonymous
  • Как добавить пользователя LDAP в бизнес-объекты SAP (cms) с помощью SAP BIPRWS
    Anonymous » » в форуме JAVA
    0 Ответы
    24 Просмотры
    Последнее сообщение Anonymous
  • SAP JCo JAVA Не удалось инициализировать класс com.sap.conn.jco.JCo.
    Anonymous » » в форуме JAVA
    0 Ответы
    71 Просмотры
    Последнее сообщение Anonymous
  • SAP JCo JAVA Не удалось инициализировать класс com.sap.conn.jco.JCo.
    Anonymous » » в форуме JAVA
    0 Ответы
    18 Просмотры
    Последнее сообщение Anonymous

Вернуться в «JAVA»