You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "Jacques Le Roux (JIRA)" <ji...@apache.org> on 2012/12/22 10:29:12 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=13538707#comment-13538707 ] 

Jacques Le Roux commented on OFBIZ-5100:
----------------------------------------

Quoting Carsten on dev ML
{quote}
Hello Tarun,


I think this might be very closelv related to OFBIZ-5090. You might want to check.

The delegator name to use should IMHO be a parameter in the Servlet Context. Of course it could then be any name.

While 5090 goes more into the use and storage of delgators during Servlet lifecycle, yours might be more around instantiation. However, we might use the two for a common approach to declare and use delegators.

Regards


Carsten

Gesendet mit BlackBerry® Webmail von Telekom Deutschland  
{quote}
                
> 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