[ https://issues.apache.org/jira/browse/OFBIZ-5377?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13810499#comment-13810499 ]
Christian Carlow commented on OFBIZ-5377: ----------------------------------------- After lengthy analysis I think the best and most flexible way to implement this functionality would be to implement an additional makeCondition function that accepts a view-link subquery/inner-select entity-alias along with the entity-condition parameters: public static <T extends EntityCondition> EntityConditionList<T> makeCondition(List<T> conditionList, EntityJoinOperator operator, String entityAlias); The entityAlias string could be used to access inner entities and apply the condition to them by using something like an entity alias fully qualified name. For example, passing the value "OS" as the entityAlias parameter to the makeCondition function to set the shipmentId of the subquery mentioned above. I think my query above would actually require creating an otherwise exact copy <view-entity> of the OrderShipment entity in order for it to be joined as a subquery. Anytime a condition is supposed to be applied to an inner entity the system should automatically join it as a subquery. The methods responsible for generating subqueries of view-entities would have to be changed to account for the extra conditions that are supposed to be applied to them. Seems like quite a bit of work. Has no one really ever needed this functionality? > Add ability to join entitites with parameterized conditions to other entities > ----------------------------------------------------------------------------- > > Key: OFBIZ-5377 > URL: https://issues.apache.org/jira/browse/OFBIZ-5377 > Project: OFBiz > Issue Type: Improvement > Reporter: Christian Carlow > > OFBiz should be improved to allow entities with parameterized conditions to > be joined with other entities. > I need to be able to apply a condition to the OrderShipment entity where > OrderShipment.shipmentId = parameters.shipmentId which might produce this > query: > SELECT * ORDER_SHIPMENT WHERE SHIPMENT_ID = '10000'; > Then I need to be able to take that query and join it to the > OrderItemShipGroupAssoc entity to product a query such as this: > SELECT * FROM ORDER_ITEM_SHIP_GROUP_ASSOC OISGA LEFT JOIN (SELECT * FROM > ORDER_SHIPMENT WHERE SHIPMENT_ID = '10000') OS ON OISGA.ORDER_ID = > OS.ORDER_ID AND OISGA.ORDER_ITEM_SEQ_ID = OS.ORDER_ITEM_SEQ_ID AND > OISGA.SHIP_GROUP_SEQ_ID = OS.SHIP_GROUP_SEQ_ID -- This message was sent by Atlassian JIRA (v6.1#6144)