You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2026/07/24 08:51:00 UTC

[jira] [Commented] (OFBIZ-5100) Delegator name is expected to be always "default" which is not the right approac

    [ https://issues.apache.org/jira/browse/OFBIZ-5100?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18098804#comment-18098804 ] 

ASF subversion and git services commented on OFBIZ-5100:
--------------------------------------------------------

Commit 2c5ae5ad013af220371a5c4db6b83c85c68a480d in ofbiz-framework's branch refs/heads/trunk from Mridul Pathak
[ https://gitbox.apache.org/repos/asf?p=ofbiz-framework.git;h=2c5ae5ad01 ]

Fixed: EntityExpr no longer hardcodes the "default" delegator when validating condition types (OFBIZ-5100)

EntityExpr.checkRhsType() always resolved DelegatorFactory.getDelegator("default")
instead of using the delegator actually running the query, so any setup using a
non-"default"-named delegator could throw GenericEntityException when building a
WHERE clause. The real delegator was already available at every call site in
GenericDAO; it just wasn't being passed down.

Threads the real Delegator through EntityCondition.makeWhereString(...) as a new
backward-compatible default method, and forwards it through every condition type
that wraps or combines other conditions (EntityConditionList, EntityFieldMap,
EntityNotCondition, EntityConditionBuilder) down to EntityExpr.checkRhsType(),
which now skips RHS type validation instead of guessing at "default" when no
delegator is available.


> Delegator name is expected to be always "default" which is not the right approac
> --------------------------------------------------------------------------------
>
>                 Key: OFBIZ-5100
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-5100
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: Release 10.04
>         Environment: All Environments
>            Reporter: Tarun Kumar
>            Assignee: Mridul Pathak
>            Priority: Major
>              Labels: entity-condition, entityengine
>
> h4. Problem
> For the below delegator configuration with a delegator.find call to a view Entity Engine is throwing error due wrong code in EntityExpr class
> {code:xml}
>     <delegator name="newName" entity-model-reader="main" entity-group-reader="main">
>         <group-map group-name="pegasus" datasource-name="pegasus"/>
>         <group-map group-name="Bookstore" datasource-name="bookstore"/>
>     </delegator>
> {code:xml}
> The code in EntityExpr.java
> {code:java}
>       if (delegator == null) {
>             // this will be the common case for now as the delegator isn't available where we want to do this
>             // we'll cheat a little here and assume the default delegator
>             delegator = DelegatorFactory.getDelegator("default");
>         }
> {code}
> assumes the delegator name is default, instead it should use the delegator name kept in xml configuration.
> h4. How to reproduce?
> 1. Change the delegator name to something else from "default"
> 2. Keep a view in entitymodel.xml
> {code:xml}
>     <view-entity entity-name="simpleView"
>                  package-name="org.ofbiz.entity.dummy"
>                  title="Dummy">
>     <member-entity entity-alias="cl" entity-name="c1"/>
>     <member-entity entity-alias="ac" entity-name="a1"/>
>     <alias-all entity-alias="ac" name="id" />
>     <alias-all entity-alias="cl" name="id"/>
>     <alias-all entity-alias="cl" name="firstName"/>
>     <alias-all entity-alias="cl" name="sponsor"/>
>     <alias-all entity-alias="ac" name="title"/>
>     <view-link entity-alias="ac" rel-entity-alias="cl">
>        <key-map field-name="id" rel-field-name="id"/>
>     </view-link>
>     <relation type="one" title="one" rel-entity-name="cl">
>             <key-map field-name="id" />
>     </relation>
>     </view-entity>
> {code}
> 3. Use this like below,
> {code:java}
> Delegator delegator = DelegatorFactory.getDelegator("newName");
> List<EntityExpr> expr=UtilMisc.toList(EntityCondition.makeCondition("sponsor",EntityOperator.EQUALS, Long.valueOf("1")));
> EntityListIterator listIterator=delegator.find("simpleView", EntityCondition.makeCondition(expr, EntityOperator.OR), null,fieldToSelct, UtilMisc.toList("id"), null);
> {code}
> It will throw GenericEntityException due to "default" is hard coded in EntityExpr.java
> Please let me know if I can submit a patch for this to avoid hard coded delegator name.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)