INDEXED JSON
{
"softDel" : 0,
"addInfo" : {
"addInfoMap" : {
"reason" : "Order picklist success",
"@type" : "RedisAdditionalInfoDTOSubType",
"grStatus" : "COMPLETED",
"documentIdList" : [
"DOC1006",
"DOC1008",
"DOC1009"
],
"deliveryTracking" : [
{
"documentId" : "DOC1006",
"status" : "ENDORSED TO COURIER",
"date" : "2022-09-21 21:14:14"
},
{
"documentId" : "DOC1008",
"status" : "ENDORSED TO COURIER",
"date" : "2022-09-21 21:14:14"
},
{
"documentId" : "DOC1009",
"status" : "ENDORSED TO COURIER",
"date" : "2022-09-21 21:14:14"
},
{
"documentId" : "DOC1006",
"status" : "INTRANSIST",
"date" : "2022-10-21 21:14:14",
"remarks" : "Moved to intransist"
},
{
"documentId" : "DOC1008",
"status" : "INTRANSIST",
"date" : "2022-10-21 21:14:14",
"remarks" : "Moved to intransist"
},
{
"documentId" : "DOC1009",
"status" : "INTRANSIST",
"date" : "2022-10-21 21:14:14",
"remarks" : "Moved to intransist"
},
{
"documentId" : "DOC1006",
"status" : "DELIVERED",
"date" : "2022-10-21 21:14:14",
"remarks" : "Moved to intransist"
},
{
"documentId" : "DOC1008",
"status" : "DELIVERED",
"date" : "2022-10-21 21:14:14",
"remarks" : "Moved to intransist"
},
{
"documentId" : "DOC1009",
"status" : "DELIVERED",
"date" : "2022-10-21 21:14:14",
"remarks" : "Moved to intransist"
},
{
"status" : "COMPLETED",
"date" : "2022-10-18:13:05:04",
"remarks" : "GRN COMPLETED"
}
],
"sapSaleOrderId" : "12349876",
"orderPicklistStatus" : "true",
"notifySSIS" : "false",
"deliveryStatus" : "COMPLETED"
}
},
"cancellationDate" : null,
"cancellationReason" : null,
"category" : "pavan",
"completionDate" : null,
"description" : null,
"expectedCompletionDate" : null,
"externalId" : null,
"href" : null,
"id" : "40281082843e13a40184401f17fd007d",
"notificationContact" : null,
"orderDate" : "2022-11-04T00:51:30.419000000+05:30",
"priority" : "1",
"productOrderBlueprintMapping" : {
"availableRetry" : 2,
"changeDate" : "2022-11-04T00:53:44.000000000Z",
"createDate" : "2022-11-04T00:53:44.000000000Z",
"dependency" : null,
"formName" : null,
"id" : 1,
"merged" : 0,
"milestoneExpiryDate" : "2022-09-21T00:57:01.626000000Z",
"orderPaused" : 0,
"orderStartDate" : "2022-09-21T00:57:01.626000000Z",
"ponr" : 0,
"priority" : "1",
"processInstanceId" : null,
"productId" : "40281082843e13a40184401f17fb007c",
"status" : "CREATED",
"taskId" : null,
"transactionId" : null,
"uniqueId" : null,
"workflowMaster" : {
"bpmnFileName" : "SapSaleOrderCreation.bpmn",
"id" : 1,
"workFlowId" : "SaleOrderCreationId",
"workflowName" : "SAP_SALE_ORDER_CREATION"
}
},
"productOrderChannels" : {
"softDel" : 0
},
"productOrderItem" : {
"softDel" : 0,
"action" : "add",
"bluePrintId" : null,
"id" : "40281082843e13a40184401f17fb007c",
"productOrderItemType" : "bdl",
"productRefOrValue" : {
"softDel" : 0
},
"quantity" : 1,
"state" : "ACKNOWLEDGED"
},
"relatedParty" : [
{
"softDel" : 0,
"href" : null,
"name" : "c8b46baa-36ba-43a5-9e13-3a3c69deb466",
"role" : "CreatedBy"
},
{
"softDel" : 0,
"href" : null,
"name" : "RD",
"role" : "DistributorType"
},
{
"softDel" : 0,
"href" : null,
"name" : "10001",
"role" : "DistributorId"
},
{
"softDel" : 0,
"href" : null,
"name" : "138849340104300105",
"role" : "AddressId"
}
],
"requestedCompletionDate" : null,
"requestedStartDate" : null,
"state" : "ACKNOWLEDGED",
"_entity_type" : "ProductOrderEntity"
}
Projection class
public class ProductOrderProjection implements Serializable{
private static final long serialVersionUID = 1L;
private String id;
private String href;
private OffsetDateTime cancellationDate;
private String cancellationReason;
private String category;
private OffsetDateTime completionDate;
private String description;
private OffsetDateTime expectedCompletionDate;
private String externalId;
private String notificationContact;
private OffsetDateTime orderDate;
private String priority;
private OffsetDateTime requestedCompletionDate;
private OffsetDateTime requestedStartDate;
private ProductOrderStateType state;
private List<ProductOrderItemProjection> productOrderItem;
private List<RelatedPartyProjection> relatedParty;
private List<ProductOrderBlueprintMappingProjection> productOrderBlueprintMapping;
private AdditionalInfoProjection addInfo;
@ProjectionConstructor
public ProductOrderProjection(String id, String href, OffsetDateTime cancellationDate, String cancellationReason,
String category, OffsetDateTime completionDate, String description, OffsetDateTime expectedCompletionDate,
String externalId, String notificationContact, OffsetDateTime orderDate, String priority,
OffsetDateTime requestedCompletionDate, OffsetDateTime requestedStartDate, ProductOrderStateType state,
List<ProductOrderItemProjection> productOrderItem, List<RelatedPartyProjection> relatedParty,
List<ProductOrderBlueprintMappingProjection> productOrderBlueprintMapping,
AdditionalInfoProjection addInfo) {
super();
this.id = id;
this.href = href;
this.cancellationDate = cancellationDate;
this.cancellationReason = cancellationReason;
this.category = category;
this.completionDate = completionDate;
this.description = description;
this.expectedCompletionDate = expectedCompletionDate;
this.externalId = externalId;
this.notificationContact = notificationContact;
this.orderDate = orderDate;
this.priority = priority;
this.requestedCompletionDate = requestedCompletionDate;
this.requestedStartDate = requestedStartDate;
this.state = state;
this.productOrderItem = productOrderItem;
this.relatedParty = relatedParty;
this.productOrderBlueprintMapping = productOrderBlueprintMapping;
this.addInfo = addInfo;
}
}
public class ProductOrderBlueprintMappingProjection implements Serializable{
private static final long serialVersionUID = 1L;
private String productId;
private String priority;
private String status;
private String uniqueId;
private int merged;
private String dependency;
private String processInstanceId;
private Date createDate;
private Date changeDate;
private String transactionId;
private String taskId;
private String formName;
private Integer availableRetry;
private int ponr;
private Date orderStartDate;
private Integer orderPaused;
private Date milestoneExpiryDate;
private WorkflowMasterProjection workflowMaster;
@ProjectionConstructor
public ProductOrderBlueprintMappingProjection(String productId, String priority, String status, String uniqueId,
int merged, String dependency, String processInstanceId, Date createDate, Date changeDate,
String transactionId, String taskId, String formName, Integer availableRetry, int ponr, Date orderStartDate,
Integer orderPaused, Date milestoneExpiryDate) {
super();
this.productId = productId;
this.priority = priority;
this.status = status;
this.uniqueId = uniqueId;
this.merged = merged;
this.dependency = dependency;
this.processInstanceId = processInstanceId;
this.createDate = createDate;
this.changeDate = changeDate;
this.transactionId = transactionId;
this.taskId = taskId;
this.formName = formName;
this.availableRetry = availableRetry;
this.ponr = ponr;
this.orderStartDate = orderStartDate;
this.orderPaused = orderPaused;
this.milestoneExpiryDate = milestoneExpiryDate;
}
}
public class WorkflowMasterProjection implements Serializable{
private static final long serialVersionUID = 1L;
private Integer id;
private String workflowName;
private String workFlowId;
private String bpmnFileName;
@ProjectionConstructor
public WorkflowMasterProjection(Integer id, String workflowName, String workFlowId, String bpmnFileName) {
super();
this.id = id;
this.workflowName = workflowName;
this.workFlowId = workFlowId;
this.bpmnFileName = bpmnFileName;
}
}
CODE to retrive data:
ElasticsearchSearchResult<ProductOrderProjection> elasticResponse = Search.session(entityManager).search(ProductOrderEntity.class)
.extension(ElasticsearchExtension.get())
.select(ProductOrderProjection.class)
.where(f -> f.fromJson(json)).fetch(offset, limit);
ERROR:
Error occured:
org.hibernate.search.util.common.SearchException: HSEARCH400655: Invalid cardinality for projection on field 'productOrderBlueprintMapping.workflowMaster.id': the projection is single-valued, but this field is effectively multi-valued in this context, because parent object field 'productOrderBlueprintMapping' is multi-valued. Either call '.multi()' when you create the projection on field 'productOrderBlueprintMapping.workflowMaster.id', or wrap that projection in an object projection like this: 'f.object("productOrderBlueprintMapping").from(<the projection on field productOrderBlueprintMapping.workflowMaster.id>).as(...).multi()'.
HI Team can u please help me with this.