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

Carsten Schinzer commented on OFBIZ-5100:
-----------------------------------------

My last sentence should end with a question mark "?" not a colon":".
                
> 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
>              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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to