[jira] Created: (OFBIZ-299) Alternative delegators do not work - entity engine refers back to "default"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (OFBIZ-299) Alternative delegators do not work - entity engine refers back to "default"

Nicolas Malin (Jira)
Alternative delegators do not work - entity engine refers back to "default"
---------------------------------------------------------------------------

                 Key: OFBIZ-299
                 URL: http://issues.apache.org/jira/browse/OFBIZ-299
             Project: OFBiz (The Open for Business Project)
          Issue Type: Bug
          Components: framework
    Affects Versions: SVN trunk
            Reporter: Marco Risaliti


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?

It's a copy of the old-jira issue OFBIZ-466

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (OFBIZ-299) Alternative delegators do not work - entity engine refers back to "default"

Nicolas Malin (Jira)
     [ http://issues.apache.org/jira/browse/OFBIZ-299?page=all ]

Jacopo Cappellato updated OFBIZ-299:
------------------------------------

    Description:
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?



  was:
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?

It's a copy of the old-jira issue OFBIZ-466


> Alternative delegators do not work - entity engine refers back to "default"
> ---------------------------------------------------------------------------
>
>                 Key: OFBIZ-299
>                 URL: http://issues.apache.org/jira/browse/OFBIZ-299
>             Project: OFBiz (The Open for Business Project)
>          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.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira