[ http://jira.undersunconsulting.com/browse/OFBIZ-466?page=comments#action_13968 ] David E. Jones commented on OFBIZ-466: --------------------------------------
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? > Alternative delegators do not work - entity engine refers back to "default" > --------------------------------------------------------------------------- > > Key: OFBIZ-466 > URL: http://jira.undersunconsulting.com/browse/OFBIZ-466 > Project: [OFBiz] Open For Business > Type: Bug > Components: entity > Versions: SVN > Reporter: Si Chen > Assignee: Jira Administrator > Fix For: SVN > > > 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. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.undersunconsulting.com/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
