[ 
https://issues.apache.org/jira/browse/OFBIZ-299?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jacopo Cappellato closed OFBIZ-299.
-----------------------------------

    Resolution: Incomplete

> Alternative delegators do not work - entity engine refers back to "default"
> ---------------------------------------------------------------------------
>
>                 Key: OFBIZ-299
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-299
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: SVN trunk
>            Reporter: Marco Risaliti
>
> It's a copy of the old-jira issue 
> http://jira.undersunconsulting.com/browse/OFBIZ-466 from Si Chen.
> Creating GenericValues using alternative delegators does not work IF those 
> GenericValues are of entities not defined in the  "default" delegator. This 
> is because the entity engine keeps referring back to "default" to look for 
> entity meta definition. 
> For example, in GenericDelegator.makeValue(entityName, fields) - 
>         GenericValue value = GenericValue.create(entity, fields); 
>         value.setDelegator(this); 
> GenericValue is created without passing in a delegator first. So how does it 
> know which delegator to use? GenericEntity.getDelegator() forces a default - 
> if (delegatorName == null) delegatorName = "default"; 
> We've had similar issues when trying to .create(...) or .createOrStore(...) 
> The entity engine needs a GenericPK, which it also looks for from the 
> "default" delegator. 
> One work around we found was to create GenericValues this way-- 
> GenericDelegator altDelegator = GenericDelegator.getGenericDelegator("<alt 
> delegator>"); 
> EntityReader altReader = altDelegator.getModelReader(); 
> ModelEntity modelEntity = reader.getModelEntity("<entityName>"); 
> GenericValue newVal = GenericValue.create(modelEntity); 
> newVal.setDelegator(altDelegator); 
> newVal.putAll(<Map of values>); 
> This can fix the GenericDelegator.makeValue(...) methods, but unfortunately 
> the resulting GenericValue still cannot be stored.
>  
>  
>  All    Comments    Work Log    Change History       Sort Order:   
> Comment by Marco Risaliti [13/Sep/06 10:43 AM] [ Permlink ] 
> Hi Si & David, 
> did you know if this issue is still open or we can close it ? 
> Thanks 
> Marco 
> Comment by David E. Jones [13/Sep/06 01:37 PM] [ Permlink ] 
> I'd appreciate more feedback from Si on this one. 
> The GenericValue, GenericPK, and GenericEntity objects are designed to always 
> be associated with a delegator. If no delegator is associated it will default 
> to the "default" delegator. However, if you use the makeValue method from a 
> different delegator it will be associated with that delegator... 
> Is there something you found not working this way Si? 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to